Boost logo

Boost :

Subject: Re: [boost] [function_types] Number of default parameters
From: Jeffrey Lee Hellrung, Jr. (jhellrung_at_[hidden])
Date: 2011-02-08 20:49:58


On 2/8/2011 5:38 PM, Lorenzo Caminiti wrote:
> Hello all,
>
> Is there a way to determine at compile-time the number of parameters
> with default values from a function type?

The following test proggy suggestions "no" :( Default parameters aren't
part of the signature of a function.

#include <iostream>

#include <boost/mpl/assert.hpp>

void f(int) { }
void g(int = 0) { }

typedef int yes_t;
typedef char no_t;
template< class T > yes_t is_same(T,T);
template< class T, class U > no_t is_same(T,U);

int main()
{
     BOOST_MPL_ASSERT_RELATION( sizeof( is_same(&f,&g) ), ==, sizeof(
yes_t ) );
     return 0;
}

- Jeff


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