diff --git a/src/memory.hh b/src/memory.hh index 26b506a6..7aaff5fe 100644 --- a/src/memory.hh +++ b/src/memory.hh @@ -30,6 +30,7 @@ enum class MemoryDomain Registers, Client, WordDB, + Selections, Count }; @@ -54,6 +55,7 @@ inline const char* domain_name(MemoryDomain domain) case MemoryDomain::Values: return "Values"; case MemoryDomain::Registers: return "Registers"; case MemoryDomain::Client: return "Client"; + case MemoryDomain::Selections: return "Selections"; case MemoryDomain::Count: break; } kak_assert(false); @@ -118,6 +120,15 @@ bool operator!=(const Allocator& lhs, const Allocator& rhs) return d1 != d2; } +template +struct TypeDomain +{ + static constexpr MemoryDomain domain = TypeDomain::helper((T*)nullptr); +private: + template static decltype(U::Domain) constexpr helper(U*) { return U::Domain; } + static constexpr MemoryDomain helper(...) { return MemoryDomain::Undefined; } +}; + } #endif // memory_hh_INCLUDED diff --git a/src/selection.hh b/src/selection.hh index 8370df1f..cc435aed 100644 --- a/src/selection.hh +++ b/src/selection.hh @@ -11,6 +11,8 @@ using CaptureList = Vector; // A selection is a Selection, associated with a CaptureList struct Selection { + static constexpr MemoryDomain Domain = MemoryDomain::Selections; + Selection() = default; Selection(ByteCoord pos) : Selection(pos,pos) {} Selection(ByteCoord anchor, ByteCoord cursor, @@ -68,6 +70,8 @@ enum class InsertMode : unsigned struct SelectionList { + static constexpr MemoryDomain Domain = MemoryDomain::Selections; + SelectionList(Buffer& buffer, Selection s); SelectionList(Buffer& buffer, Selection s, size_t timestamp); SelectionList(Buffer& buffer, Vector s); diff --git a/src/unordered_map.hh b/src/unordered_map.hh index b114df69..2c54a0da 100644 --- a/src/unordered_map.hh +++ b/src/unordered_map.hh @@ -9,7 +9,7 @@ namespace Kakoune { -template +template::domain> using UnorderedMap = std::unordered_map, std::equal_to, Allocator, domain>>; diff --git a/src/vector.hh b/src/vector.hh index 987b80f9..db137b24 100644 --- a/src/vector.hh +++ b/src/vector.hh @@ -8,7 +8,7 @@ namespace Kakoune { -template +template::domain> using Vector = std::vector>; }