From 13039e1dfe462d7944a662cb5626674a7183e8be Mon Sep 17 00:00:00 2001 From: JCW Date: Mon, 8 Jun 2026 16:05:46 +0100 Subject: [PATCH] Fix build errors for windows --- include/xrpl/basics/TaggedCache.h | 25 ++++++++++++++++++++++--- include/xrpl/basics/TaggedCache.ipp | 28 +--------------------------- 2 files changed, 23 insertions(+), 30 deletions(-) diff --git a/include/xrpl/basics/TaggedCache.h b/include/xrpl/basics/TaggedCache.h index 7ea939c47d..c3d8cf5579 100644 --- a/include/xrpl/basics/TaggedCache.h +++ b/include/xrpl/basics/TaggedCache.h @@ -18,6 +18,22 @@ namespace xrpl { +namespace detail { + +// Replace-policy tags selecting how TaggedCache::canonicalizeImpl resolves a +// collision when the key already exists (defined in TaggedCache.ipp): +// - ReplaceCached: always replace the cached value with `data`. `data` is +// never written back and may be const. +// - ReplaceClient: keep the cached value and write it back into `data` (the +// client's pointer), which must therefore be writable. +// - ReplaceDynamically: call the supplied callback to decide per call; `data` +// is written back when the cached value is kept, so it must be writable. +struct ReplaceCached; +struct ReplaceClient; +struct ReplaceDynamically; + +} // namespace detail + /** Map/cache combination. This class implements a cache and a map. The cache keeps objects alive in the map. The map allows multiple code paths that reference objects @@ -100,9 +116,12 @@ public: private: // Selects the `data` parameter type of canonicalizeImpl from the replace // policy: const for detail::ReplaceCached (never written back), otherwise - // writable. Defined in TaggedCache.ipp. + // writable. template - struct CanonicalizeClientPointerType; + using CanonicalizeClientPointerType = std::conditional_t< + std::is_same_v, + SharedPointerType const&, + SharedPointerType&>; /** Shared implementation of the canonicalize family. @@ -116,7 +135,7 @@ private: bool canonicalizeImpl( key_type const& key, - typename CanonicalizeClientPointerType::Type data, + CanonicalizeClientPointerType data, Policy policy, Callback&& replaceCallback = nullptr); diff --git a/include/xrpl/basics/TaggedCache.ipp b/include/xrpl/basics/TaggedCache.ipp index c813374e85..6973ec4ba0 100644 --- a/include/xrpl/basics/TaggedCache.ipp +++ b/include/xrpl/basics/TaggedCache.ipp @@ -29,32 +29,6 @@ struct ReplaceDynamically } // namespace detail -template < - class Key, - class T, - bool IsKeyCache, - class SharedWeakUnionPointer, - class SharedPointerType, - class Hash, - class KeyEqual, - class Mutex> -template -struct TaggedCache< - Key, - T, - IsKeyCache, - SharedWeakUnionPointer, - SharedPointerType, - Hash, - KeyEqual, - Mutex>::CanonicalizeClientPointerType -{ - using Type = std::conditional_t< - std::is_same_v, - SharedPointerType const&, - SharedPointerType&>; -}; - template < class Key, class T, @@ -355,7 +329,7 @@ inline bool TaggedCache:: canonicalizeImpl( key_type const& key, - typename CanonicalizeClientPointerType::Type data, + CanonicalizeClientPointerType data, [[maybe_unused]] Policy policy, [[maybe_unused]] Callback&& replaceCallback) {