
4 Apr
2009
4 Apr
'09
11:06 a.m.
Hello, I wish to have a metafct that adds "const &" to types that have it or don't have it... template< typename T > struct add_const_ref { typedef typename boost::remove_const<T>::type t1; typedef typename boost::add_const<t1>::type t2; typedef typename boost::add_reference<t2>::type type; }; Does this exist already in type traits or elsewhere? I couldn't find.... Can this be improved in terms of reducing the number of tmpl instantiations? Note : add_const_ref< const double& >::type is const double& for e.g. Rds,