Boost logo

Boost Users :

From: John Maddock (john_at_[hidden])
Date: 2005-02-17 08:30:32


>> FWIW, you will soon be able to get that effect without a metafunction.
>> from http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#106
>> [example]
>> int i;
>> typedef int& RI;
>> RI& r = i; // r has the type int&
>> const RI& r = i; // r has the type const int&
>> [/example]
>>
>> I'm not sure I like it, because a 'RI const' is 'int&', but a reference
>> to a
>> 'RI const' is 'int const&'. But maybe its useful that way.
>
> Oh, that's very disturbing. What is the rationale for moving the
> const inside the reference?
>
> Ah, I see it in N1245:
>
> template<class T> class X { f(const T&) ; /* ... */ };
>
> X<int&> x; // X<int&>::f has the argument type const int&
>
> I'm not convinced that special rule is worth the breath and text
> needed to explain it. With any well-behaved class X, if f was written
> to work on a "const X&" argument, it will work equally well and
> correctly on a "X&" argument.
>
> It's probably too late for objections now, though.

I don't think this affects add_const as such:

Adding a const qualifier to a reference type still has no effect, it's only
when you add a reference qualifier to a reference type that the
cv-qualifiers get combined in this way.

Assuming I've understood correctly of course!

John.


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