Boost logo

Boost Users :

From: David Abrahams (dave_at_[hidden])
Date: 2005-01-10 10:30:12


Ben Hutchings wrote:

> Well the first attempt doesn't solve the problem because it requires an
> extra parameter. The second attempt solves it but I don't think you're
> supposed to make use of other templates.

Any solutions is allowable, though that one is not particularly elegant.

> I think the expected solution
> would be more like this:
>
> template<typename T>
> struct add_const_ref
> {
> typename T const & type;
> };
>
> template<typename T>
> struct add_const_ref<T &>
> {
> typename T & type;
> };

Actually there's a much more concise solution using the type traits
library. That is, after all, the focus of the chapter.

-- 
Dave Abrahams
Boost Consulting
http://www.boost-consulting.com

Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net