From 3c3d45d94c66cb922f8c622b28590f9c115f58f1 Mon Sep 17 00:00:00 2001 From: Vraiment Date: Sun, 30 Jul 2017 23:44:28 -0700 Subject: [PATCH] Added TupleHasType class for template metaprogramming --- SDL2pp/Private/Utility.hh | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/SDL2pp/Private/Utility.hh b/SDL2pp/Private/Utility.hh index 7ba47f0..67e6403 100644 --- a/SDL2pp/Private/Utility.hh +++ b/SDL2pp/Private/Utility.hh @@ -28,9 +28,9 @@ #include #endif +#include #include - namespace SDL2pp { /* * This is code not to be used directly by users of SDL2pp. @@ -93,6 +93,25 @@ namespace Private { template using And = typename AndOperation::type; #endif + +/* + * Templated class to an specific type in a tuple, returns std::true_type if the + * tuple contains T, std::false_type otherwise. + */ +template +struct TupleHasTypeOperation; + +template +struct TupleHasTypeOperation> : std::false_type { }; + +template +struct TupleHasTypeOperation> : TupleHasTypeOperation> { }; + +template +struct TupleHasTypeOperation> : std::true_type { }; + +template +using TupleHasType = typename TupleHasTypeOperation::type; } }