B
Brice Gagnage
Hi folks,
Given this piece of code:
std::map< int, std::unique_ptr< int > > map;
std::for_each( std::begin( map ), std::end( map ),
[&] ( const std:air< int, std::unique_ptr< int > >& pair )
{
cout << pair.first;
} );
My compiler pops an error: for_each is trying to create a pair, thus taking
map elements' unique_ptr's as parameters. At this point, I don't understand
why for_each has to create a pair, since I'm asking explicitly for a const ref
in my lambda. Is there any way to make this map work with this algorithm ?
Any help appreciated.
Thanks in advance,
Given this piece of code:
std::map< int, std::unique_ptr< int > > map;
std::for_each( std::begin( map ), std::end( map ),
[&] ( const std:air< int, std::unique_ptr< int > >& pair )
{
cout << pair.first;
} );
My compiler pops an error: for_each is trying to create a pair, thus taking
map elements' unique_ptr's as parameters. At this point, I don't understand
why for_each has to create a pair, since I'm asking explicitly for a const ref
in my lambda. Is there any way to make this map work with this algorithm ?
Any help appreciated.
Thanks in advance,