|
Boost : |
Subject: Re: [boost] Proposal regarding "boost::add_const".
From: John Maddock (boost.regex_at_[hidden])
Date: 2010-05-23 12:17:11
> First of all, this is my first boost posting, and as all I could find on
> "http://lists.boost.org/mailman/listinfo.cgi/boost" told my to post my
> proposal to this address, I did so (despite of being astonished, that
> there does not seem to be a directory of subgroups to browse.).
> However, at least on MSVC 9 as well as on ICL 11 there exists the
> problem, that the "BOOST_MPL_ASSERT" terms in the attached
> "consten.rar\consten\consten.cpp" do fail for "boost::add_const" but not
> for "consten", meaning, that "boost::add_const" was not capable to add
> constness to reference-types, which "consten" is.
> Hence my proposal is, to create a service-pack to "boost::add_const"
> based on "consten" and similarly to all other affected traits, such as
> "boost::add_volatile" and the like.
That's not how add_const is supposed to work - it's supposed to be the same
as "T const" (where that is allowed) and if T is a reference type U&, then
the result is still U&. If you want add_const to work as you suggest then
you would need to compose the type_traits as follows:
mpl::if_<
is_reference<T>,
add_reference<add_const<remove_reference<T>::type>::type>::type,
add_const<T>::type
>::type
HTH, John.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk