Boost logo

Boost Users :

From: Duane Murphy (duanemurphy_at_[hidden])
Date: 2006-12-19 13:05:22


--- At Tue, 19 Dec 2006 11:46:40 +0100, Thorsten Ottosen wrote:

>Duane Murphy wrote:
>> I'm trying to use boost::ptr_map<> and cannot get calls insert to compile.
>>
>> I'm on Mac OS X using gcc 3.3 with Xcode.
>>
>> Even the most basic code fails to compile:
>>
>> boost::ptr_map< in, int* > my_map;
>> int * val = new int( 22 );
>> my_map.insert( 1, val );
>
>See http://www.boost.org/libs/ptr_container/doc/ptr_map_adapter.html
>
>The first argument needs to be a reference:
>
>int key = 1;
>my_map.insert( key, new int(22) );
>
>1.34 adds the followinf overload:
>
> template< class U >
> std::pair<iterator,bool>
> insert( const key_type& key, std::auto_ptr<U> x )
>
>which does allow the key to be an rvalue (just don't create the auto_ptr
>in the function call).

And here I was assuming it was something to do with the value...

Thank you. I now recall reading something about that, but it wasn't
clear to me at the time that it was talking about the key.

This fixes the problem.

 ...Duane


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net