#ifndef SFINAE_H #define SFINAE_H #include /** * @brief SFINAE tool to check more than one condition in same time. Using it like this : * std::integral_constant, IsAnInputModel>::value>() */ template struct SFINAE_And_ : std::true_type { }; template struct SFINAE_And_ : std::conditional, std::false_type>::type { }; /** * @brief SFINAE tool to know if the model was an input result model that produce copies */ template class IsAResultModelCopy { class yes { char m;}; class no { yes m[2];}; struct BaseMixin { int nOutResultModelCopiesCreated() const {return 0;} }; struct Base : public Type, public BaseMixin {}; template class Helper{}; template static no deduce(U*, Helper* = 0); static yes deduce(...); public: static const bool value = sizeof(yes) == sizeof(deduce((Base*)(0))); }; /** * @brief SFINAE tool to know if the model is an output model */ template class IsAnOutputModel { class yes { char m;}; class no { yes m[2];}; struct BaseMixin { int uniqueIndex() const {return 0;} }; struct Base : public Type, public BaseMixin {}; template class Helper{}; template static no deduce(U*, Helper* = 0); static yes deduce(...); public: static const bool value = sizeof(yes) == sizeof(deduce((Base*)(0))); }; /** * @brief SFINAE tool to know if the model is an input model. If the method "uniqueIndex() const" is present * we deduce that it is an output model. */ template class IsAnInputModel { class yes { char m;}; class no { yes m[2];}; struct BaseMixin { int uniqueIndex() const {return 0;} }; struct Base : public Type, public BaseMixin {}; template class Helper{}; template static no deduce(U*, Helper* = 0); static yes deduce(...); public: static const bool value = sizeof(no) == sizeof(deduce((Base*)(0))); }; template struct HasApplicableToPoint : std::false_type{}; template struct HasApplicableToPoint : std::true_type {}; template struct HasApplicableToEdge : std::false_type{}; template struct HasApplicableToEdge : std::true_type {}; template struct HasApplicableToFace : std::false_type{}; template struct HasApplicableToFace : std::true_type {}; /** * @brief SFINAE tool to know if the handle is an abstract input handle. If the enum "MinValue" is present * we deduce that it is an concrete input handle (not abstract). */ // You need void_t to avoid a warning about the lhs of the comma operator // having no effect. C++ 17 has std::void_t template using void_t = void; template struct IsAnInputAbstractHandle { static constexpr bool value = false; }; template struct IsAnInputAbstractHandle> { static constexpr bool value = true; }; #endif // SFINAE_H