
Thorsten Ottosen wrote:
"Daniel Wallin" <dalwan01@student.umu.se> wrote in message news:407BC506.6020209@student.umu.se...
How about this:
[snip]
it's better, although I can't compile it on comeau 4.3. gcc and vc7 seems to like it. I'm know sure there can be made a normal boost-hacked implementation that will work nicely on many platforms. We just someone to do it.
OK, this works on comeau: template<class T> struct cant_mutate_const_values { typedef int type; }; template<class T> struct cant_mutate_const_values<T const> { template<class U> struct error {}; typedef typename error<T>::type type; }; template<class T> T& mutate_rvalue(T const& x) { return const_cast<T&>(x); } template<class T> T& mutate_rvalue(T& x, typename cant_mutate_const_values<T>::type = 0) { return x; } -- Daniel Wallin