Loading...
Searching...
No Matches
macro.h
Go to the documentation of this file.
1#ifndef _BBM_CONCEPT_MACRO_H_
2#define _BBM_CONCEPT_MACRO_H_
3
4#include <concepts>
5#include "core/error.h"
6#include "util/macro_util.h"
7#include "concepts/config.h"
8
9/***********************************************************************/
10/*! \file macro.h
11
12 \brief Macros for checking if a class meets a concept.
13
14 Examples:
15 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.c}
16 BBM_CHECK_RAW_CONCEPT( std::constructible_from, std::complex<float>, float, float );
17 BBM_CHECK_CONCEPT( std::constructible_from, bsdf_ptr<config>, Value_t<config> );
18 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
19
20 The first checks if std::complex<float> is constructible from 2 floats,
21 i.e., std::constructible_from< vec2d<float>, float, float> is true. This
22 check can be used in evaluated and unevaluated contexts.
23
24 The second checks if bsdf_ptr<config> is constribile from a Value_t<config>
25 where config is a archetypical bbm configuration. BBM_CHECK_CONCEPT ensure
26 that bbm::concepts::archetype is in the namespace. This check can only be
27 used in an unevaluated context.
28
29************************************************************************/
30
31//! \brief Check a class for a concept
32#define BBM_CHECK_RAW_CONCEPT(CONCEPTNAME, CLASSNAME, ...) static_assert( CONCEPTNAME<CLASSNAME __VA_OPT__(,) __VA_ARGS__>, BBM_ERROR_MSG(#CLASSNAME does not meet #CONCEPTNAME) );
33
34//! \brief Check a class for a concept with bbm::concepts::archetypes in the namespace
35#define BBM_CHECK_CONCEPT(CONCEPTNAME, CLASSNAME, ...) \
36 template<string_literal, size_t> void concept_check(void); \
37 template<> void concept_check<__FILE__,__LINE__>(void) \
38 { \
39 using namespace bbm::concepts::archetype; \
40 BBM_CHECK_RAW_CONCEPT(CONCEPTNAME, CLASSNAME __VA_OPT__(,) __VA_ARGS__); \
41 } \
42
43#endif /* _BBM_CONCEPT_MACRO_H_ */
config contract
Predefined exceptions for common errors.
General macro utilities.