From 4f706906d46d17fa8006653bad25f2ecf25f4c7d Mon Sep 17 00:00:00 2001 From: Bernhard Manfred Gruber Date: Wed, 8 Dec 2021 13:37:53 +0100 Subject: [PATCH] refactor RecordCoord algorithms Works around an MSVC compilation failure --- include/llama/RecordCoord.hpp | 54 +++++++++++++---------------------- 1 file changed, 20 insertions(+), 34 deletions(-) diff --git a/include/llama/RecordCoord.hpp b/include/llama/RecordCoord.hpp index 79600ba3a4..e22b5b8008 100644 --- a/include/llama/RecordCoord.hpp +++ b/include/llama/RecordCoord.hpp @@ -117,59 +117,45 @@ namespace llama namespace internal { - template - struct RecordCoordCommonPrefixIsBiggerImpl; - template - struct RecordCoordCommonPrefixIsBiggerImpl, RecordCoord> + constexpr auto recordCoordCommonPrefixIsBiggerImpl(RecordCoord, RecordCoord) -> bool { - static constexpr auto value = []() constexpr + // CTAD does not work if Coords1/2 is an empty pack + std::array a1{Coords1...}; + std::array a2{Coords2...}; + for(std::size_t i = 0; i < std::min(a1.size(), a2.size()); i++) { - // CTAD does not work if Coords1/2 is an empty pack - std::array a1{Coords1...}; - std::array a2{Coords2...}; - for(std::size_t i = 0; i < std::min(a1.size(), a2.size()); i++) - { - if(a1[i] > a2[i]) - return true; - if(a1[i] < a2[i]) - return false; - } - return false; + if(a1[i] > a2[i]) + return true; + if(a1[i] < a2[i]) + return false; } - (); + return false; }; } // namespace internal /// Checks wether the first RecordCoord is bigger than the second. template inline constexpr auto RecordCoordCommonPrefixIsBigger - = internal::RecordCoordCommonPrefixIsBiggerImpl::value; + = internal::recordCoordCommonPrefixIsBiggerImpl(First{}, Second{}); namespace internal { - template - struct RecordCoordCommonPrefixIsSameImpl; - template - struct RecordCoordCommonPrefixIsSameImpl, RecordCoord> + constexpr auto recordCoordCommonPrefixIsSameImpl(RecordCoord, RecordCoord) -> bool { - static constexpr auto value = []() constexpr - { - // CTAD does not work if Coords1/2 is an empty pack - std::array a1{Coords1...}; - std::array a2{Coords2...}; - for(std::size_t i = 0; i < std::min(a1.size(), a2.size()); i++) - if(a1[i] != a2[i]) - return false; - return true; - } - (); + // CTAD does not work if Coords1/2 is an empty pack + std::array a1{Coords1...}; + std::array a2{Coords2...}; + for(std::size_t i = 0; i < std::min(a1.size(), a2.size()); i++) + if(a1[i] != a2[i]) + return false; + return true; }; } // namespace internal /// Checks whether two \ref RecordCoord%s are the same or one is the prefix of the other. template inline constexpr auto RecordCoordCommonPrefixIsSame - = internal::RecordCoordCommonPrefixIsSameImpl::value; + = internal::recordCoordCommonPrefixIsSameImpl(First{}, Second{}); } // namespace llama