|
Boost Users : |
From: Foster, Gareth (gareth.foster_at_[hidden])
Date: 2004-10-28 03:36:12
This randomly made me wonder ...
if(const int * == int const *)
Is that just a personal preference thing?
Gaz
-----Original Message-----
From: boost-users-bounces_at_[hidden]
[mailto:boost-users-bounces_at_[hidden]] On Behalf Of Peter Dimov
Sent: 26 October 2004 14:21
To: boost-users_at_[hidden]
Subject: Re: [Boost-users] gcc-3.4.1 and add_const
Alexander Neubeck wrote:
> Hi.
>
> I recognized a strange (wrong?) behaviour of gcc-3.4.1 (and
> gcc-3.3.3).
> When adding const to a type T and this type T is a reference, the
> result is just T again (with reference, but witout const)!
> Then I tested, if boost handles this case correctly, and it didn't.
> The type of add_const< int & >::result is int & and not as expected
> const int &.
Your expectation was wrong. A "const" reference to int is not the same as a
reference to a const int.
[...]
> My questions to you:
> Can anybody verify this behaviour?
> Is this behaviour intended?
> If yes, WHY?
Because that's how top-level const works. int * const != int const *, and
int & const != int const &.
> P.S:
> It was quite difficult to check, which result-type the add_const
> really created. First I used typeid( ... ).name(). But then I
> recognized that int, int &, const int & produce ALL THE SAME name?!?
Yes, that's how typeid works.
_______________________________________________
Boost-users mailing list
Boost-users_at_[hidden]
http://lists.boost.org/mailman/listinfo.cgi/boost-users
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