diff --git a/cpp/Platform.Data.Tests/ILinksTests.cpp b/cpp/Platform.Data.Tests/ILinksTests.cpp index 99159b5..78199e9 100644 --- a/cpp/Platform.Data.Tests/ILinksTests.cpp +++ b/cpp/Platform.Data.Tests/ILinksTests.cpp @@ -1,9 +1,9 @@ namespace Platform::Data::Tests { - template VConstants = LinksConstants{true}, typename TLink = std::vector, typename TReadHandler = std::function, typename TWriteHandler = std::function> - struct Links : public ILinks> + template, typename TLink = std::vector, typename TReadHandler = std::function, typename TWriteHandler = std::function> + struct Links : public ILinks> { - using base = ILinks>; + using base = ILinks>; using typename base::LinkAddressType; using typename base::LinkType; using typename base::WriteHandlerType; diff --git a/cpp/Platform.Data/ILinks.h b/cpp/Platform.Data/ILinks.h index d16cf01..5b70f30 100644 --- a/cpp/Platform.Data/ILinks.h +++ b/cpp/Platform.Data/ILinks.h @@ -7,7 +7,8 @@ public: using LinksOptionsType = TLinksOptions; using LinkAddressType = typename LinksOptionsType::LinkAddressType; - static constexpr LinksConstants Constants = LinksOptionsType::Constants; + using LinksConstantsType = typename LinksOptionsType::LinksConstantsType; + static constexpr LinksConstantsType Constants = LinksOptionsType::Constants; using LinkType = typename LinksOptionsType::LinkType; using ReadHandlerType = typename LinksOptionsType::ReadHandlerType; using WriteHandlerType = typename LinksOptionsType::WriteHandlerType; diff --git a/cpp/Platform.Data/LinksConstants.h b/cpp/Platform.Data/LinksConstants.h index e55b4ed..92cc098 100644 --- a/cpp/Platform.Data/LinksConstants.h +++ b/cpp/Platform.Data/LinksConstants.h @@ -3,6 +3,7 @@ template struct LinksConstants { + using LinkAddressType = TLinkAddress; static constexpr int DefaultTargetPart = 2; public: const TLinkAddress IndexPart{}; diff --git a/cpp/Platform.Data/LinksConstantsExtensions.h b/cpp/Platform.Data/LinksConstantsExtensions.h index 630a17a..3225670 100644 --- a/cpp/Platform.Data/LinksConstantsExtensions.h +++ b/cpp/Platform.Data/LinksConstantsExtensions.h @@ -1,21 +1,23 @@ namespace Platform::Data { - template VLinksConstants> - static bool IsInternalReference(TLinkAddress linkAddress) noexcept + template + static bool IsInternalReference(typename TLinksConstants::LinkAddressType linkAddress) noexcept { - return VLinksConstants.InternalReferencesRange.Contains(linkAddress); + static constexpr TLinksConstants constants{true}; + return constants.InternalReferencesRange.Contains(linkAddress); } - template VLinksConstants> - static bool IsReference(TLinkAddress linkAddress) noexcept + template + static bool IsReference(typename TLinksConstants::LinkAddressType linkAddress) noexcept { - return IsInternalReference(VLinksConstants, linkAddress) || IsExternalReference(VLinksConstants, linkAddress); + return IsInternalReference(linkAddress) || IsExternalReference(linkAddress); } - template VLinksConstants> - static bool IsExternalReference(TLinkAddress linkAddress) noexcept + template + static bool IsExternalReference(typename TLinksConstants::LinkAddressType linkAddress) noexcept { - auto&& range = VLinksConstants.ExternalReferencesRange; + static constexpr TLinksConstants constants{true}; + auto&& range = constants.ExternalReferencesRange; return range.Contains(linkAddress); } } diff --git a/cpp/Platform.Data/LinksOptions.h b/cpp/Platform.Data/LinksOptions.h index c33f8ad..264e839 100644 --- a/cpp/Platform.Data/LinksOptions.h +++ b/cpp/Platform.Data/LinksOptions.h @@ -1,14 +1,15 @@ namespace Platform::Data { - template VConstants = LinksConstants{true}, typename TLink = std::vector, typename TReadHandler = std::function, typename TWriteHandler = std::function> + template, typename TLink = std::vector, typename TReadHandler = std::function, typename TWriteHandler = std::function> struct LinksOptions { using LinkAddressType = TLinkAddress; using LinkType = TLink; using ReadHandlerType = TReadHandler; using WriteHandlerType = TWriteHandler; - static constexpr LinksConstants Constants = VConstants; + using LinksConstantsType = TLinksConstants; + static constexpr TLinksConstants Constants{true}; }; // template