pavo kristiani
pavo kristiani

Reputation: 35

Error while compilation of std::map with boost::shared_ptr

I am trying to compile my code in vs2005. I am using std::map and boost::shared_ptr (v1.47.0) My code looks something like this

struct B {
    int a;
}
typedef boost::shared_ptr<B> K;

std::map<const std::string, K > mymap;

//some code

std::map<const std::string, K >::iterator it;
for (it = mymap.begin(); it < mymap.end(); it++ )
{
     //do something
}

The compiler is giving an error at the for statement. The following is the error

error C2784: 'bool boost::operator <(const boost::intrusive_ptr &,const boost::intrusive_ptr &)' : could not deduce template argument for 'const boost::intrusive_ptr &' from 'std::_Tree<_Traits>::iterator'.

Any help is appreciated. Thank you.

Upvotes: 0

Views: 185

Answers (1)

Some programmer dude
Some programmer dude

Reputation: 409166

You are using the wrong operator for the checking against mymap.end(). Change the loop to

for (it = mymap.begin(); it != mymap.end(); it++ )

Upvotes: 1

Related Questions