2013/9/25 Mostafa
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
#include #include #include #include using namespace boost;
typedef void (foo)(int const);
int main() {
typedef function_traits<foo>::arg1_**type traits_deduced_type; BOOST_MPL_ASSERT(( is_same
)); //Errors: //BOOST_MPL_ASSERT(( is_same )); typedef boost::function_types::**parameter_types<foo> ftypes_params; typedef boost::mpl::at
>::type ftypes_deduced_type; BOOST_MPL_ASSERT(( is_same )); //Errors: //BOOST_MPL_ASSERT(( is_same )); return 0; }
Mostafa
The two function declarations: void f(int); void f(int const); declare the same function, not an overload. 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. So in your example, I think the compiler correctly discards the 'const'. Regards, Kris