Boost logo

Boost :

Subject: Re: [boost] [type_traits][function_types] Discard param const qualification, bug or feature?
From: Rob Stewart (robertstewart_at_[hidden])
Date: 2013-09-26 05:32:46


On Sep 25, 2013, at 10:59 AM, Mostafa <mostafa_working_away_at_[hidden]> wrote:

> On Wed, 25 Sep 2013 02:09:19 -0700, Andrey Semashev <andrey.semashev_at_[hidden]> wrote:
>
>> I have to say that while these rules are logical and understandable when
>> explained, types of function arguments are a constant source of confusion.
>
> Exactly. That's why an explanatory note or two in the documentation would go a long way.

Offer a documentation patch and it might be applied.

>> The described above quirk with const arguments can be considered quite rare
>> as people usually don't declare arguments that way.
>
> It can show up in some meta-programming code. Say you want to capture a value by const and let the meta-programmed code forward it to some destination, and for the sake of efficiency you decided to the forwarding by reference. If you're not careful, you can end up with an 'int &' to an 'int const' in the meta-programmed code.

You can create an int & to a copy of an int const, but not to an int const.

___
Rob

(Sent from my portable computation engine)


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk