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-25 04:48:50


On Sep 25, 2013, at 2:57 AM, Krzysztof Czainski <1czajnik_at_[hidden]> wrote:

> 2013/9/25 Mostafa <mostafa_working_away_at_[hidden]>
>
>> Both the type_traits and function_types library discard parameter const-qualifiers when decomposing function types. Is this a bug or a
>> feature? If a feature, then it's surprising enough behaviour that I think it warrants some documentation in both libraries.

[snip]

>> typedef void (foo)(int const);
>
> The two function declarations:
> void f(int);
> void f(int const);
> declare the same function, not an overload.

Right. Top level const is not part of the function's type.

> Const added to an argument type passed by value doesn't change the function signature. It is because the parameter will be copied anyway, and the const refers to how the argument
> will be treated inside the function's implementation.

Exactly.

___
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