Boost logo

Boost :

From: David Abrahams (dave_at_[hidden])
Date: 2005-06-06 10:11:40


"Eric Niebler" <eric_at_[hidden]> writes:

> Howard Hinnant wrote:
>> The scary part is that we do so many useful things these days by
>> tentatively passing non-POD's past an ellipses, though only at
>> compile time, never at run time. But the compiler is not making
>> that distinction.
>> This is a big problem, and I suspect it will need to be addressed at
>> the standards level. I don't have a solution yet.
>>
>
>
> The solution is to not pass non-PODs through ellipses, of course. ;-)
>
> double is_mem_fun_ptr_tester(...);
>
> template<typename Class, typename Ret>
> char is_mem_fun_ptr_tester(Ret (Class::**)());
>
> template<typename T>
> struct is_member_function_pointer
> {
> BOOST_STATIC_CONSTANT(bool,
> value = 1==sizeof(is_mem_fun_ptr_tester(static_cast<T*>(0))));
> };
>
> typedef char test1[
> is_member_function_pointer<void (dummy::*)()>::value ];
> typedef char test2[
> !is_member_function_pointer<dummy>::value ];

You have to take some steps to eliminate the formation of
pointers-to-references, i.e. a partial specialization on compilers
that support it and some wretched mess everywhere else.

-- 
Dave Abrahams
Boost Consulting
www.boost-consulting.com

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