Boost logo

Boost Users :

From: Martin Ecker (martin.ecker_at_[hidden])
Date: 2007-07-22 00:08:11


Hi,

Is there a way, using SFINAE tricks and potentially the techniques
used in the Boost Concept Check Library, to detect at compile-time if
a type T supports a certain expression? In my case, I'm interested if
T supports operator ==. So I'm basically looking for a compile-time
predicate so that this compiles:

struct my_struct { int i; };
struct my_struct2 { int i; };
bool operator == (my_struct2 const&, my_struct2 const&) const;

BOOST_STATIC_ASSERT((supports_comparison_operator<int>::value));
BOOST_STATIC_ASSERT((!supports_comparison_operator<my_struct>::value));
BOOST_STATIC_ASSERT((supports_comparison_operator<my_struct2>::value));

Thanks,
Martin


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net