
9 Feb
2011
9 Feb
'11
1:49 a.m.
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