Boost logo

Boost :

Subject: Re: [boost] [IdentityType] Const omission undocumented.
From: Krzysztof Czainski (1czajnik_at_[hidden])
Date: 2013-12-03 14:23:46


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:
> >>
> >> #include <boost/utility/identity_type.hpp>
> >> #include <utility>
> >>
> >> int main()
> >> {
> >> BOOST_IDENTITY_TYPE(( std::pair<int,int> const )) x;
> >> // This compiles, so the const qualification in the
> >> // above macro parameter is ignored.
> >> x = std::make_pair(0,1);
> >>
> >> return 0;
> >> }
> >>
> >> The omission of const qualification in BOOST_IDENTITY_TYPE types is
> >> undocumented. This omission maybe deduced from the documented
> >> implementation, but, as noted, that is not part of the library api and
> >> is subject to change. I therefore propose that this behaviour be
> >> documented as part of the library's public api.
> >
> >
> > That looks like a bug.
>
> Is there a way to extract the cv-qualifier from a function parameter
> type at compile-time?
>
> some_mata_function<void (int const)>::type // evaluates to `int const`
> not just `int`
>
> Right now I do the following which looses the cv-qualifier (I also
> tried to program my own meta-functions but I wan't able to retain the
> cv-qualifier).
>
> boost::function_traits<void (int const)>::arg1_type // evaluates to
> `int` and not to `int conat` :(
>

how about (not tested):
boost::remove_reference< boost::function_traits<void (int
const&)>::arg1_type >::type

Regards,
Kris


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