
23 Jul
2007
23 Jul
'07
5:22 p.m.
Hi, i'm trying to modify rvalue container using Boost.ForEach: #include <string> #include <vector> #include <boost/foreach.hpp> typedef std::vector<std::string> vec; inline boost::mpl::true_ * boost_foreach_is_lightweight_proxy(vec *&, boost::foreach::tag) { return 0; } vec GetVector() { vec v; v.push_back("hello"); v.push_back("world"); return v; } int main() { // compiles ok GetVector().push_back("oh god, it's writable!"); // next line gives "unable to convert `const string' to `string&'" BOOST_FOREACH(std::string& String, GetVector()) String.clear(); return 0; } It doen't compiles (MCVC 8.0) - it looks like boost_foreach_is_lightweight_proxy is ignored. What's wrong?