|
Boost Users : |
From: Raider (sraider_at_[hidden])
Date: 2007-07-23 13:22:23
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?
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net