Hi,
The current boost::associative_property_map interface in
boost::property_map does not provide a *find()* function interface from
where we can find a key type from associative map.
Although the associative property map concept was mainly developed for
using boost::get and boost::put function efficiently on unique associative
containers (such as std::map), it still does not have any interface for
using find() function for searching whether an element exists in a map, My
problem is explained below:
I have a map, and I define a associative property map on it. as follows:
std::map< int, int > *mymap*;
boost::associative_property_map< std::map< int, int > > *my_asso_map* (
mymap );
I have a template function, named " exists_in " which checks whether a
particular key_value, is present in the map or not. The function is as
follows:
*template*
bool *exists_in*(map_t map, key_t key)
{
return map.*find*(key) != map.end();
}
========================================
If I call this template function on mymap, it gives me no error: if(
!exists_in ( mymap, key ) ----> no error
Now, if I call template function on my_asso_map, it throws an error : if(
!exists_in( my_asso_map, key ) ---->> error
error: âclass boost::associative_property_map >â has no
member named âendâ
error: âclass boost::associative_property_map >â has no
member named âfindâ
I understand, my_asso_map just stores the address of mymap and provides get
and put efficiently. But there are instances, where I have to *search* a
key in my map. ( for example, if else loop as provided above ).
I want to hide *mymap *and just expose *my_asso_map* to the user and
everywhere I want to pass my_asso_map.. I am able to do this except for the
*find*() function, because of which I had to keep passing my original
*mymap *to the function/ functor and then use exists_in template function.
Is there any way to implement a find() utility for associative property
maps ? If find() interface can be added in library, that would be simply
great !
Thanks,
--
Thanks and regards,
Aniket Pugaonkar