ECCE @ EIC Software
Reference for
ECCE @ EIC
simulation and reconstruction software on GitHub
|
#include <acts/blob/master/Core/include/Acts/Utilities/TypeTraits.hpp>
Public Member Functions | |
~nonesuch ()=delete | |
nonesuch (nonesuch const &)=delete | |
void | operator= (nonesuch const &)=delete |
This file contains an implementation of the detection idiom in C++. It's not currently in the standard, but can be implemented using standard features. This implementation is largely taken from the C++ technical specifications, library fundamentals v2
The detector pattern works like this: there is a default type, that accepts an "operation" that can be basically anything. It also accepts variadic arguments for that operation. The default type has a member type that is std::false_type to indicate success or failure. It also has a member type "type" which captures a type result. Then there is a specialization which attempts to instantiate the operation with the given parameters, and tries to assign it into std::void_t. If the operation fails to instantiate (say, the checked for type does not exist), the specialization will not be instantiated, and the compiler falls back to the default type which contains std::false_type. Since it happens inside while the compiler tries to find a better matching template specialization than the default one (so basically overload resolution), a compile error inside the operation is handled as a substitution failure, and is not an error. If the instantiation succeeds, the specialization contains a std::true_type, and an alias to the result of the operation.
Essentially, it provides a convenient way to "lift" operations into this overload resolution, allowing testing expressions and evaluating them into compile time booleans (instead of compilation failures). Helper struct which cannot be constructed (or destroyed) at all.
Definition at line 50 of file TypeTraits.hpp.
View newest version in sPHENIX GitHub at line 50 of file TypeTraits.hpp
|
delete |
|
delete |