$include_dir="/home/hyper-archives/boost-users/include"; include("$include_dir/msg-header.inc") ?>
From: Thorsten Ottosen (thorsten.ottosen_at_[hidden])
Date: 2008-04-19 10:19:30
Nat Goodspeed skrev:
> Robert Dailey wrote:
>
>> I have the following code:
>>
>> void HandlePair( std::pair<int, char*>& mypair )
>> {
>> }
>>
>> void main()
>> {
>> boost::ptr_map<int, char> mymap;
>> HandlePair( *mymap.begin() );
>> }
>>
>>
>> What's the proper way to accept pairs in the HandlePair function?
>
> I'd suggest basing it on your actual ptr_map type, e.g.:
> void HandlePair(const boost::ptr_map<int, char>::value_type& mypair) {}
Actually, using
void HandlePair(boost::ptr_map<int, char>::const_reference mypair);
is better, since the reference type is not a real reference. So
don't rely on map::reference to be equal to map::value_type&.
HTH
-Thorsten