[typeof] How to know whether a expression is void?

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?

"Atry" <pop.atry@gmail.com> 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

Arkadiy Vertleyb wrote:
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.
Here is the link: http://lists.boost.org/Archives/boost/2006/01/98906.php -- Alexander Nasonov http://nasonov.blogspot.com Criticism is prejudice made plausible. -- Henry Mencken -- This quote is generated by: /usr/pkg/bin/curl -L http://tinyurl.com/veusy \ | sed -e 's/^document\.write(.//' -e 's/.);$/ --/' \ -e 's/<[^>]*>//g' -e 's/^More quotes from //' \ | fmt | tee ~/.signature-quote
participants (3)
-
Alexander Nasonov
-
Arkadiy Vertleyb
-
Atry