diff --git a/SDL2pp/Private/Utility.hh b/SDL2pp/Private/Utility.hh index e0fb6df..7ba47f0 100644 --- a/SDL2pp/Private/Utility.hh +++ b/SDL2pp/Private/Utility.hh @@ -64,6 +64,35 @@ namespace Private { template using Or = typename OrOperation::type; #endif + +/* + * Templated class to perform an "AND" operation on any amount of types. + * + * Usage is as follows: + * template , HasFeatureTwo> + * void UseFeatureOneAndFeatureTwo(T t) { + * // The code will be only compiled if both + * // HasFeatureOne and HasFeatureTwo are type_true + * } + */ +#if __cplusplus >= 201703L + // Use the standard definitions if they are available + template + using And = typename std::conjunction::type; +#else + template + struct AndOperation : std::true_type { }; + + template + struct AndOperation : T { }; + + template + struct AndOperation : std::conditional, T> { }; + + template + using And = typename AndOperation::type; +#endif } }