
19 Apr
2008
19 Apr
'08
2:19 p.m.
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