summaryrefslogtreecommitdiff
path: root/src/flags.hh
diff options
context:
space:
mode:
authorMaxime Coste <mawww@kakoune.org>2017-03-15 17:55:34 +0000
committerMaxime Coste <mawww@kakoune.org>2017-03-15 18:00:58 +0000
commitdb9b863222dbd51154c422cf85bc8fafacd5b25b (patch)
treec64d4a42ff62372736d747a1ab25568954ba6e32 /src/flags.hh
parenta49e175727928b8b45c0c2ccdb01f143ea6d18c2 (diff)
Migrate WithBitOps template specialization to with_bit_ops function
This way we dont depend on knowing the base template to enable bit ops on an enum type.
Diffstat (limited to 'src/flags.hh')
-rw-r--r--src/flags.hh8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/flags.hh b/src/flags.hh
index d9755efa..74a7188f 100644
--- a/src/flags.hh
+++ b/src/flags.hh
@@ -3,20 +3,22 @@
#include <type_traits>
+#include "meta.hh"
+
namespace Kakoune
{
template<typename Flags>
-struct WithBitOps : std::false_type {};
+constexpr bool with_bit_ops(Meta::Type<Flags>) { return false; }
template<typename Flags>
using UnderlyingType = typename std::underlying_type<Flags>::type;
template<typename Flags, typename T = void>
-using EnableIfWithBitOps = typename std::enable_if<WithBitOps<Flags>::value, T>::type;
+using EnableIfWithBitOps = typename std::enable_if<with_bit_ops(Meta::Type<Flags>{}), T>::type;
template<typename Flags, typename T = void>
-using EnableIfWithoutBitOps = typename std::enable_if<not WithBitOps<Flags>::value, T>::type;
+using EnableIfWithoutBitOps = typename std::enable_if<not with_bit_ops(Meta::Type<Flags>{}), T>::type;
template<typename Flags, typename = EnableIfWithBitOps<Flags>>
constexpr Flags operator|(Flags lhs, Flags rhs)