Boost logo

Boost :

Subject: Re: [boost] [IdentityType] Const omission undocumented.
From: Lorenzo Caminiti (lorcaminiti_at_[hidden])
Date: 2013-12-03 17:53:06


On Tue, Dec 3, 2013 at 1:39 PM, Mostafa <mostafa_working_away_at_[hidden]> wrote:
> On Tue, 03 Dec 2013 11:23:46 -0800, Krzysztof Czainski <1czajnik_at_[hidden]>
>> 2013/12/3 Lorenzo Caminiti <lorcaminiti_at_[hidden]>
>>> On Sat, Nov 16, 2013 at 11:18 AM, Mathias Gaunard
>>> <mathias.gaunard_at_[hidden]> wrote:
>>> > On 16/11/2013 01:02, Mostafa wrote:
>>> > That looks like a bug.
>>>
>>> Is there a way to extract the cv-qualifier from a function parameter
>>> type at compile-time?
>>
>> how about (not tested):
>> boost::remove_reference< boost::function_traits<void (int
>> const&)>::arg1_type >::type
>
> Pointers should be used instead. References will lead to bugs because of
> reference collapsing when add_reference is used. For example:
>
> BOOST_IDENTITY_TYPE(( std::pair<int,int> & )) x;
>
> will be incorrectly deduced as std::pair<int,int>

I can't change the tokens "(int const)" because these are specified by
the user of BOOST_IDENTITY_TYPE(tokens) (and I cannot inspect them
within the outermost parenthesis without variadic macros, which is the
point of Boost.IdentityType). So I cannot do (int const&), (int
const*), etc :(

--Lorenzo


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