Loading...
Searching...
No Matches
Macros
macro.h File Reference

Macros for checking if a class meets a concept. More...

#include <concepts>
#include "core/error.h"
#include "util/macro_util.h"
#include "concepts/config.h"

Go to the source code of this file.

Macros

#define BBM_CHECK_RAW_CONCEPT(CONCEPTNAME, CLASSNAME, ...)   static_assert( CONCEPTNAME<CLASSNAME __VA_OPT__(,) __VA_ARGS__>, BBM_ERROR_MSG(#CLASSNAME does not meet #CONCEPTNAME) );
 Check a class for a concept.
 
#define BBM_CHECK_CONCEPT(CONCEPTNAME, CLASSNAME, ...)
 Check a class for a concept with bbm::concepts::archetypes in the namespace.
 

Detailed Description

Macros for checking if a class meets a concept.

Examples:

BBM_CHECK_RAW_CONCEPT( std::constructible_from, std::complex<float>, float, float );
BBM_CHECK_CONCEPT( std::constructible_from, bsdf_ptr<config>, Value_t<config> );
#define BBM_CHECK_CONCEPT(CONCEPTNAME, CLASSNAME,...)
Check a class for a concept with bbm::concepts::archetypes in the namespace.
Definition: macro.h:35
#define BBM_CHECK_RAW_CONCEPT(CONCEPTNAME, CLASSNAME,...)
Check a class for a concept.
Definition: macro.h:32

The first checks if std::complex<float> is constructible from 2 floats, i.e., std::constructible_from< vec2d<float>, float, float> is true. This check can be used in evaluated and unevaluated contexts.

The second checks if bsdf_ptr<config> is constribile from a Value_t<config> where config is a archetypical bbm configuration. BBM_CHECK_CONCEPT ensure that bbm::concepts::archetype is in the namespace. This check can only be used in an unevaluated context.

Macro Definition Documentation

◆ BBM_CHECK_CONCEPT

#define BBM_CHECK_CONCEPT (   CONCEPTNAME,
  CLASSNAME,
  ... 
)
Value:
template<string_literal, size_t> void concept_check(void); \
template<> void concept_check<__FILE__,__LINE__>(void) \
{ \
using namespace bbm::concepts::archetype; \
BBM_CHECK_RAW_CONCEPT(CONCEPTNAME, CLASSNAME __VA_OPT__(,) __VA_ARGS__); \
} \
bsdfmodel archetype for concept checking
Definition: bsdfmodel.h:154

Check a class for a concept with bbm::concepts::archetypes in the namespace.

◆ BBM_CHECK_RAW_CONCEPT

#define BBM_CHECK_RAW_CONCEPT (   CONCEPTNAME,
  CLASSNAME,
  ... 
)    static_assert( CONCEPTNAME<CLASSNAME __VA_OPT__(,) __VA_ARGS__>, BBM_ERROR_MSG(#CLASSNAME does not meet #CONCEPTNAME) );

Check a class for a concept.