Boost logo

Boost :

From: Aleksey Gurtovoy (agurtovoy_at_[hidden])
Date: 2002-03-22 02:37:29

Seems that something like the following should give us an ability to check
for presence of a particulary named member [function/data] in a class:

typedef char (&no_tag)[1];
typedef char (&yes_tag)[2];

template< typename T > no_tag has_member_foo_helper(...);

template< typename T >
yes_tag has_member_foo_helper(int, void (T::*)() = &T::foo);

template< typename T >
struct has_member_foo
        , value = sizeof(has_member_foo_helper<T>(0)) == sizeof(yes_tag)

struct my {};
struct her { void foo(); };

int main()

    return 0;


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