Program Listing for File macros.hpp
↰ Return to documentation for file (include/ecl/concepts/macros.hpp
)
public:
ecl_compile_time_concept_test(MyConcept)
{
// compile time concept checks here.
}
};
/*****************************************************************************
** Ifdefs
*****************************************************************************/
#ifndef ECL_CONCEPTS_MACROS_HPP_
#define ECL_CONCEPTS_MACROS_HPP_
/*****************************************************************************
** Namespaces
*****************************************************************************/
namespace ecl {
namespace concepts {
/*****************************************************************************
** Classes
*****************************************************************************/
template <void(*)()> struct InstantiateConceptCheck {};
template <class Model>
void CONCEPT_CHECK_FAILED()
{
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wnonnull"
((Model*)0)->~Model();
#pragma GCC diagnostic pop
}
template <class Model>
struct CONCEPT_CHECK
{
InstantiateConceptCheck< CONCEPT_CHECK_FAILED<Model> > x;
enum { instantiate = 1 };
};
} // namespace concepts
} // namespace ecl
#define ecl_concept_check_name_expand(Name) ConceptCheck ## Name
#define ecl_concept_check_name(Name) ecl_concept_check_name_expand(Name)
#define ecl_compile_time_concept_check( Model ) \
enum { ecl_concept_check_name(__LINE__) = ecl::concepts::CONCEPT_CHECK< Model >::instantiate }
#define ecl_compile_time_concept_test( Model ) \
ecl_compile_time_concept_check( Model ); \
~Model()
#endif /* ECL_CONCEPTS_MACROS_HPP_ */