Boost logo

Boost :

Subject: Re: [boost] How to detect if f() returns void or not?
From: Maxime van Noppen (maxime_at_[hidden])
Date: 2009-12-12 11:27:29

joel falcou wrote:
> I fear you must resort to BOOST_TYPEOF.

The problem is that you cannot use BOOST_TYPEOF with void expressions it
seems. Here is what his code expands in :

namespace boost { namespace type_of {

    template<typename T>
        typename enable_if<is_function<T>, T&>::type

    template<typename T>
        typename disable_if<is_function<T>, T&>::type
        ensure_obj(const T&);


void returns_void();
int returns_int();

int main() {
std::cout<<boost::is_void< __typeof__(boost::type_of::ensure_obj(void))

return 0;

The ensure_obj expansion fails because T cannot be void.


Boost list run by bdawes at, gregod at, cpdaniel at, john at