diff options
| author | Maxime Coste <mawww@kakoune.org> | 2017-05-26 07:59:18 +0100 |
|---|---|---|
| committer | Maxime Coste <mawww@kakoune.org> | 2017-05-26 07:59:18 +0100 |
| commit | 6e389512f548d3efdb4f25407fb51e0cbbdc8051 (patch) | |
| tree | aba75712ba2f8a7c8832113778f341066cf0bdb9 /src/memory.hh | |
| parent | ca38e103148807c3a4b18f1e0bc36732553fcbd8 (diff) | |
Modernize the way we compute memory domains from type
Use a constexpr function instead of a template type
Diffstat (limited to 'src/memory.hh')
| -rw-r--r-- | src/memory.hh | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/src/memory.hh b/src/memory.hh index 4d41c0c0..fe6f70ea 100644 --- a/src/memory.hh +++ b/src/memory.hh @@ -6,6 +6,7 @@ #include <utility> #include "assert.hh" +#include "meta.hh" namespace Kakoune { @@ -141,14 +142,11 @@ bool operator!=(const Allocator<T1, d1>& lhs, const Allocator<T2, d2>& rhs) return d1 != d2; } + +constexpr MemoryDomain memory_domain(Meta::AnyType) { return MemoryDomain::Undefined; } + template<typename T> -struct TypeDomain -{ - static constexpr MemoryDomain domain() { return TypeDomain<T>::helper((T*)nullptr); } -private: - template<typename U> static decltype(U::Domain) constexpr helper(U*) { return U::Domain; } - static constexpr MemoryDomain helper(...) { return MemoryDomain::Undefined; } -}; +constexpr decltype(T::Domain) memory_domain(Meta::Type<T>) { return T::Domain; } template<MemoryDomain d> struct UseMemoryDomain |
