boost::add_reference breaks type deduction

I am trying to use boost:add_reference in a template function to protect against the reference of reference problems, but it is breaking type deduction and I was wondering if any one know of a solution to this. template<typename Type> read(std::istream& stream, Type& data); This works properly of course. ----------------------------------------- template<typename Type> read (std::istream& stream, typename boost::add_reference<Type>::type data); This one does not work properly and I have to explicitly specify the type. Judd Tracy Assistant in Simulation Institute for Simulation and Training University of Central Florida

"Judd Tracy" <jtracy@ist.ucf.edu> writes:
I am trying to use boost:add_reference in a template function to protect against the reference of reference problems, but it is breaking type deduction and I was wondering if any one know of a solution to this.
template<typename Type> read(std::istream& stream, Type& data);
This works properly of course.
And it's already protected. If you are passing a reference type U& as the 2nd argument, Type will always be deduced as U. You don't need add_reference here.
-----------------------------------------
template<typename Type> read (std::istream& stream, typename boost::add_reference<Type>::type data);
This one does not work properly and I have to explicitly specify the type.
-- Dave Abrahams Boost Consulting http://www.boost-consulting.com
participants (2)
-
David Abrahams
-
Judd Tracy