|
Boost : |
From: Arkadiy Vertleyb (vertleyb_at_[hidden])
Date: 2007-06-05 09:47:22
"Atry" <pop.atry_at_[hidden]> wrote
> Hi everybody, I have an template function, and I want to know if it return
> void, but it does not work:
>
>
> template<typename T>
> struct is_foo_void : boost::is_void<BOOST_TYPEOF(T::foo(123))>{};
>
> struct foo_struct
> {
> template<typename T>
> static void foo(T){}
> };
>
> BOOST_STATIC_ASSERT(is_foo_return_void<foo_struct>::value);
> ////////////////////////////////////////////////////////////
> Yes, I know funtion_traits would be help if I have a non-template
> function,
> but in this case I can't, what should I do?
Boost.Typeof is unable to deduce the "void" type. This is because typeof is
ultimately beased on the type deduction mechanism provided by C++ when
passing an expression to a template function, such as:
template<class T>
<size-of-return-type-depends-on-T> foo(const T&);
Since it's not possible to pass a void expression to a function,
Boost.Typeof can't handle this type.
An idea of how to handle void inside typeof was suggested by Alexander
Nasonov in the past, but it has not been implemented so far.
Regards,
Arkadiy
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk