
9 Aug
2009
9 Aug
'09
6:38 a.m.
Hello Rob,
To enable writing to the element.second, shouldn't that 'second' extractor return a reference?
Good point, and that's certainly possible to do. The function object needs to be changed like so (note that the argument to the function call operator is now passed as a reference rather than reference to const): // Extract the second element of a pair template <typename T> class pair_second_t { public: typedef T& result_type; template <typename U> result_type operator()(std::pair& element) const { return element.second; } }; Cheers, Bjorn Karlsson www.skeletonsoftware.net