Boost logo

Boost :

Subject: [boost] [type_traits][function_types] Discard param const qualification, bug or feature?
From: Mostafa (mostafa_working_away_at_[hidden])
Date: 2013-09-25 02:13:52


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. For the record, I'm
using gcc 4.7.3 on Cygwin 1.7.22 in Windows 7, and here's a reproducible
example of what I'm talking about:

#include <boost/type_traits.hpp>
#include <boost/function_types/parameter_types.hpp>
#include <boost/mpl/at.hpp>
#include <boost/mpl/int.hpp>
#include <boost/mpl/assert.hpp>

using namespace boost;

typedef void (foo)(int const);

int main()
{

   typedef function_traits<foo>::arg1_type traits_deduced_type;
   BOOST_MPL_ASSERT(( is_same<traits_deduced_type, int> ));
   //Errors:
   //BOOST_MPL_ASSERT(( is_same<traits_deduced_type, int const> ));

   typedef boost::function_types::parameter_types<foo> ftypes_params;
   typedef boost::mpl::at<ftypes_params, boost::mpl::int_<0> >::type
     ftypes_deduced_type;
   BOOST_MPL_ASSERT(( is_same<ftypes_deduced_type, int> ));
   //Errors:
   //BOOST_MPL_ASSERT(( is_same<ftypes_deduced_type, int const> ));

   return 0;
}

Mostafa


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