E

#### er

code.

#include <utility>

#include <boost/mpl/assert.hpp>

#include <boost/type_traits/is_reference.hpp>

#include <boost/type_traits/is_const.hpp>

#include <boost/type_traits/remove_reference.hpp>

#include <boost/type_traits/remove_const.hpp>

// Implem developed under CPP03 that I'd like to not have to re-write

under CPP0x

template<typename T> void impl(T&){}

// CPP03

template<typename T> void f(T& t){ impl( t ); }

template<typename T> void f(T const& t){ impl( t ); }

// CPP0x - tentative replacement for f

template<typename T> void g(T&& t)

{

impl(

std::forward<T>( t )

// what should I have here, instead, such that I can emulate the

behavior of f when t is a rvalue?

);

}

int const x = -1;

f( x );

f( 1 );

g( x );

g( 1 ); // fails.

// sheds light on the problem:

template<typename T>

void assert_lvalue(T&&)

{

typedef boost::is_reference<T> pred_;

BOOST_MPL_ASSERT((pred_));

}

template<typename T>

void assert_rvalue(T&&)

{

typedef boost::is_reference<T> pred_;

BOOST_MPL_ASSERT_NOT((pred_));

}

template<typename T>

void assert_const(T&&)

{

typedef typename boost::remove_reference<T>::type val_;

typedef boost::is_const<val_> pred_;

BOOST_MPL_ASSERT((pred_));

}

assert_lvalue( x );

assert_const( x );

assert_rvalue( 1 );

assert_const( 1 ); // mpl::failed