MIRA
Namespaces | Macros
HasMember.h File Reference

Macros for checking the existence of class members. More...

#include <boost/type_traits/integral_constant.hpp>
#include <boost/type_traits/is_class.hpp>
Include dependency graph for HasMember.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Namespaces

 mira
 specialize cv::DataType for our ImgPixel and inherit from cv::DataType<Vec>
 

Macros

#define MIRA_MEMBER_DETECTOR_EX(Identifier, Member)
 
#define MIRA_MEMBER_DETECTOR(Member)   MIRA_MEMBER_DETECTOR_EX(Member,Member)
 
#define MIRA_HAS_MEMBER(Class, Identifier)   MIRAHasMemberCheck##Identifier<MIRAHasMemberCheckTrait<Class>::type>
 Macro checking the existence of a class member. More...
 
#define MIRA_HAS_MEMBER_TEMPLATE(Class, Identifier)   MIRAHasMemberCheck##Identifier<typename MIRAHasMemberCheckTrait<Class>::type>
 

Detailed Description

Macros for checking the existence of class members.

Author
Erik Einhorn
Date
2010/06/30

Macro Definition Documentation

◆ MIRA_MEMBER_DETECTOR_EX

#define MIRA_MEMBER_DETECTOR_EX (   Identifier,
  Member 
)
Value:
template <typename Type> \
class MIRAHasMemberCheck##Identifier \
{ \
struct NotFound { char x[1]; }; \
struct Found { char x[2]; }; \
struct BaseMixin { \
void Member(){} \
}; \
\
struct Base : public Type, public BaseMixin {}; \
template <typename T, T t> class Helper{}; \
\
template <typename U> \
static NotFound deduce(U*, Helper<void (BaseMixin::*)(), &U::Member>* = 0);\
static Found deduce(...); \
\
public: \
enum { value = (sizeof(Found) == sizeof(deduce((Base*)(0))))}; \
typedef boost::integral_constant<bool, \
(sizeof(Found) == sizeof(deduce((Base*)(0)))) > type; \
\
};
PropertyHint type(const std::string &t)
Sets the attribute "type" to the specified value.
Definition: PropertyHint.h:295

◆ MIRA_MEMBER_DETECTOR

#define MIRA_MEMBER_DETECTOR (   Member)    MIRA_MEMBER_DETECTOR_EX(Member,Member)

◆ MIRA_HAS_MEMBER

#define MIRA_HAS_MEMBER (   Class,
  Identifier 
)    MIRAHasMemberCheck##Identifier<MIRAHasMemberCheckTrait<Class>::type>

Macro checking the existence of a class member.

class MyClass {
public:
int i;
}
if (MIRA_HAS_MEMBER(MyClass, i)::value) {
...
}

◆ MIRA_HAS_MEMBER_TEMPLATE

#define MIRA_HAS_MEMBER_TEMPLATE (   Class,
  Identifier 
)    MIRAHasMemberCheck##Identifier<typename MIRAHasMemberCheckTrait<Class>::type>