I'm pretty sure I'm have a 'Doh!' moment here, but why does this compile?
Surely the last line of main is gibberish; the value type of m is pair, not S, so int_from_S
is not a valid function?
#include <boost/range.hpp>
#include <boost/range/adaptor/transformed.hpp>
#include <map>
struct S
{
S( ) { }
int i;
};
int int_from_S( S s ) { return s.i; }
int main( )
{
std::map<unsigned, S> m;
m[0]=S();
m | boost::adaptors::transformed(int_from_S);
}
- Rob.