Boost logo

Boost :

Subject: Re: [boost] [function_types] Number of default parameters
From: Lorenzo Caminiti (lorcaminiti_at_[hidden])
Date: 2011-02-08 21:14:36

On Tue, Feb 8, 2011 at 8:50 PM, Dave Abrahams <dave_at_[hidden]> wrote:
> On Tue, Feb 8, 2011 at 8:38 PM, Lorenzo Caminiti <lorcaminiti_at_[hidden]> wrote:
>> Is there a way to determine at compile-time the number of parameters
>> with default values from a function type?
> Nope, it's not part of the type.

OK, not possible. Thanks all for the quick replies.

I'm confused because the following code doesn't compile on MSVC but it
_does_ compiles fine on GCC...

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

int main() {
    typedef void (func_type)(double num = -1.23); // NO STANDARD??

    typedef boost::function_types::parameter_types<func_type>::type param_types;
    typedef boost::mpl::at_c<param_types, 0>::type arg_type0;

    return 0;

1) Is this a bug in GCC which should not accept `= -1.23` in `func_type`?
2) Both, GCC and MSVC accept the parameter name `num` as part of the
`func_type` type. Can parameter names be specified in function types?

What does the C++ standard say?

Thanks a lot!


Boost list run by bdawes at, gregod at, cpdaniel at, john at