diff --git a/CMakeLists.txt b/CMakeLists.txt index e23b73f..18a938b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -28,6 +28,7 @@ set(HEADER_FILES math/math.h misc/memory.h misc/random.h + misc/traits.h tests/testutils.h tests/cppunit.h ) diff --git a/misc/traits.h b/misc/traits.h new file mode 100644 index 0000000..fb8aa49 --- /dev/null +++ b/misc/traits.h @@ -0,0 +1,39 @@ +#ifndef CPP_UTILITIES_TRAITS_H +#define CPP_UTILITIES_TRAITS_H + +#include + +namespace Traits { + +namespace Detail { + enum class Enabler {}; +} + +template +using Conditional = typename std::conditional::type; + +template +struct Bool : std::integral_constant {}; + +template +using Not = Bool; + +template +struct Any : Bool {}; + +template +struct All : Bool {}; + +template +struct All : Conditional, Bool > {}; + +template +using EnableIf = typename std::enable_if::value, Detail::Enabler>::type; + +template +using DisableIf = typename std::enable_if::value, Detail::Enabler>::type; + +} + +#endif // CPP_UTILITIES_TRAITS_H +