
Daniel Wallin <dalwan01@student.umu.se> writes:
David Abrahams wrote: [snip]
On the other hand, with technique 2 I think you can't write the generic function at all, because template arguments have to match exactly: template <class T> void f(const_lvalue<Y<T> > x); // can never match a Y<T> argument
Isn't this true for technique 1 as well (and everything that isn't &&)?
template<class T> void f(move_from<T> x);
Granted, you can detect lvalues in a generic function, but that isn't of much use if you can't detect temporaries, no?
Are you ready for this? template <class T> void tlsink(T volatile& y) { T const& x = const_cast<T const&>(y); } template <class T> void tlsink(T x) { SAY("in templated move sink"); } This works with EDG. GCC isn't so happy with it. I'm not sure which one is right, but I'm voting for EDG. I wonder if we can get rid of the const_cast... -- Dave Abrahams Boost Consulting http://www.boost-consulting.com