From a13ac3bf53f883112bddc04a18ce6e916f5c4765 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Sun, 8 Nov 2020 20:58:56 +0000 Subject: Untemplate hooks equal range and related bits --- slicer/slicer/hookMap.h | 39 +++++++++++++----------------------- slicer/slicer/modelPartsTypes.impl.h | 4 +++- 2 files changed, 17 insertions(+), 26 deletions(-) diff --git a/slicer/slicer/hookMap.h b/slicer/slicer/hookMap.h index 58fe014..a0763ac 100644 --- a/slicer/slicer/hookMap.h +++ b/slicer/slicer/hookMap.h @@ -13,11 +13,11 @@ namespace Slicer { public: using HookPtr = const typename ModelPartForComplex::HookBase *; - template class eq; + class eq; - template class iter : public std::iterator { + class iter : public std::iterator { public: - [[nodiscard]] constexpr inline iter(const eq * const r, const HookPtr * c) : range(r), cur(c) + [[nodiscard]] constexpr inline iter(const eq * const r, const HookPtr * c) : range(r), cur(c) { moveMatch(); } @@ -73,50 +73,39 @@ namespace Slicer { } } - const eq * const range; + const eq * const range; const HookPtr * cur; }; - template class eq { + class eq { public: - [[nodiscard]] constexpr inline iter + [[nodiscard]] constexpr inline iter begin() const { return {this, b}; } - [[nodiscard]] constexpr inline iter + [[nodiscard]] constexpr inline iter end() const { return {this, e}; } - K key; + std::string_view key; std::string_view HookCommon::*name; const HookPtr *b, *e; }; - template - [[nodiscard]] constexpr inline eq - equal_range(K && k) const - { - return {std::forward(k), &HookCommon::name, _begin, _end}; - } - - template - [[nodiscard]] constexpr inline eq - equal_range_lower(K && k) const + [[nodiscard]] constexpr inline eq + equal_range(std::string_view k) const { - return {std::forward(k), &HookCommon::nameLower, _begin, _end}; + return {k, &HookCommon::name, _begin, _end}; } - template - [[nodiscard]] inline auto - equal_range_nocase(const K & k) const + [[nodiscard]] constexpr inline eq + equal_range_lower(std::string_view k) const { - std::string i {k}; - to_lower(i); - return equal_range_lower(std::move(i)); + return {k, &HookCommon::nameLower, _begin, _end}; } [[nodiscard]] constexpr inline auto diff --git a/slicer/slicer/modelPartsTypes.impl.h b/slicer/slicer/modelPartsTypes.impl.h index 9048cf2..a008e02 100644 --- a/slicer/slicer/modelPartsTypes.impl.h +++ b/slicer/slicer/modelPartsTypes.impl.h @@ -342,7 +342,9 @@ namespace Slicer { return GetChildRefFromRange(hooks().equal_range(name), flt); } else { - return GetChildRefFromRange(hooks().equal_range_nocase(name), flt); + std::string i {name}; + to_lower(i); + return GetChildRefFromRange(hooks().equal_range_lower(i), flt); } } -- cgit v1.2.3