RE: [Boost-users] Re: C++ Template Metaprogramming - Exercise 2-0

Philippe,
Given that, it is trivial to modify Eric's solution to have the proper result.
Right. As they say in New England, Dawn in beginning to break over Marblehead. It took me four cracks to get it, but I think I got it now (see below and tell me if I do). (thanks for not telling me the answer outright) I starting to get the hang of it. Exercise 2.0 down. That's one in a row :) #include <iostream> #include <boost/type_traits/is_reference.hpp> #include <boost/type_traits/add_reference.hpp> #include <boost/type_traits/add_const.hpp> #include <boost/type_traits/is_same.hpp> #include <boost/static_assert.hpp> using namespace std; template<typename T> struct add_const_ref { typedef typename boost::add_reference<typename boost::add_const<T>::type>::type type; }; int main() { BOOST_STATIC_ASSERT((boost::is_same<boost::add_const<int>::type, const int>::value)); BOOST_STATIC_ASSERT((boost::is_same<boost::add_reference<int>::type, int&>::value)); BOOST_STATIC_ASSERT((boost::is_same<boost::add_const<int&>::type, int&>::value)); BOOST_STATIC_ASSERT((boost::is_same<boost::add_reference<boost::add_cons t<int>::type>::type, int const&>::value)); BOOST_STATIC_ASSERT((boost::is_same<add_const_ref<int&>::type, int&>::value)); BOOST_STATIC_ASSERT((boost::is_same<add_const_ref<int>::type, int const&>::value)); return 0; } Thanks for the input, Bruce
Philippe _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
participants (1)
-
Trask, Bruce (US SSA)