This simple code snippet fails to work as expected for some reason, instead requiring me to explicitly specify type for T (for the function call foo):

Does anyone know why?Code:template<typename T> void foo(typename Stuff::mpl::ArgumentHelper<T>::type Arg) { cout << Stuff::mpl::type_name<Stuff::mpl::add_const<typename Stuff::mpl::ArgumentHelper<T>::const_type>::type>::name << endl; Arg.x = 5; } class A { public: int x; }; namespace mpl = Stuff::mpl; int main() { A a; a.x = 0; foo(a); cout << a.x << endl; }

ArgumentHelper is defined as follows:

Explanations are greatly appreciated O_OCode:namespace detail { template<typename T, bool IsFundamental> struct ArgumentHelper { typedef T type; typedef T const_type; }; template<typename T> struct ArgumentHelper<T, false> { typedef typename boost::add_reference<T>::type type; typedef typename Stuff::mpl::add_const<type>::type const_type; }; } template<typename T> struct ArgumentHelper { typedef typename boost::remove_reference<typename boost::remove_const<T>::type>::type raw_type; typedef typename detail::ArgumentHelper<T, boost::is_fundamental<raw_type>::value>::type type; typedef typename detail::ArgumentHelper<T, boost::is_fundamental<raw_type>::value>::const_type const_type; };

EDIT: And how to work around it in a good way, if possible. Otherwise the whole thing is doomed.