ATLAS Offline Software
Macros
concepts.h File Reference

Compatibility helpers for using some pieces of C++20 concepts with older compilers. More...

#include <type_traits>
#include <iterator>
Include dependency graph for concepts.h:

Go to the source code of this file.

Macros

#define HAVE_CONCEPTS   0
 
#define ATH_REQUIRES(...)
 
#define ATH_MEMBER_REQUIRES(CONDITION, RETTYPE)
 
#define ATH_MEMBER_REQUIRES_DEF(CONDITION, RETTYPE)
 

Detailed Description

Compatibility helpers for using some pieces of C++20 concepts with older compilers.

Author
scott snyder snyde.nosp@m.r@bn.nosp@m.l.gov
Date
Apr, 2020 Use ATH_REQUIRES for a requires clause:
template <class T>
ATH_REQUIRES( std::assignable_from<T, float> )
void foo (T x);

The body of the ATH_REQUIRES will be hidden for compilers that don't support concepts.

ATH_MEMBER_REQUIRES can be used to selectively enable a member function. Example:

template <class T>
class C { ...
ATH_MEMBER_REQUIRES(std::is_same_v<T,int>, double) foo (double x) { ... }

declares a function foo returning double that is enabled only if T is an int. If you have a definition separate from the declaration, then use ATH_MEMBER_REQUIRES_DEF in the definition instead.

Will use a requires clause with C++20 and enable_if otherwise.

Definition in file concepts.h.

Macro Definition Documentation

◆ ATH_MEMBER_REQUIRES

#define ATH_MEMBER_REQUIRES (   CONDITION,
  RETTYPE 
)
Value:
template <bool Enable = true> \
std::enable_if_t<Enable && (CONDITION), RETTYPE>

Definition at line 113 of file concepts.h.

◆ ATH_MEMBER_REQUIRES_DEF

#define ATH_MEMBER_REQUIRES_DEF (   CONDITION,
  RETTYPE 
)
Value:
template <bool Enable> \
std::enable_if_t<Enable && (CONDITION), RETTYPE>

Definition at line 117 of file concepts.h.

◆ ATH_REQUIRES

#define ATH_REQUIRES (   ...)

Definition at line 111 of file concepts.h.

◆ HAVE_CONCEPTS

#define HAVE_CONCEPTS   0

Definition at line 109 of file concepts.h.

ATH_MEMBER_REQUIRES
#define ATH_MEMBER_REQUIRES(CONDITION, RETTYPE)
Definition: concepts.h:112
DMTest::C
C_v1 C
Definition: C.h:26
ATH_REQUIRES
#define ATH_REQUIRES(...)
Definition: concepts.h:110
x
#define x
TSU::T
unsigned long long T
Definition: L1TopoDataTypes.h:35