From 2fe62c846e3dfdff120ea88950a5b6ebe0695e4e Mon Sep 17 00:00:00 2001 From: Christopher Lackner Date: Wed, 21 Aug 2019 09:44:31 +0200 Subject: [PATCH] workaround for some compilers evaluating the declval in has_Range --- libsrc/core/array.hpp | 24 ++---------------------- libsrc/core/type_traits.hpp | 23 +++++++++++++++++++++++ 2 files changed, 25 insertions(+), 22 deletions(-) diff --git a/libsrc/core/array.hpp b/libsrc/core/array.hpp index d523d96b..dedd974e 100644 --- a/libsrc/core/array.hpp +++ b/libsrc/core/array.hpp @@ -59,27 +59,6 @@ namespace ngcore } - namespace detail - { - - // Type trait to check if a class implements a 'range_type Range()' function - template - struct has_Range - { - private: - template - static constexpr auto check(T2*) -> - std::enable_if().Range(), std::true_type> { std::true_type(); } - template - static constexpr std::false_type check(...); - using type = decltype(check(nullptr)); // NOLINT - public: - NGCORE_API static constexpr bool value = type::value; - }; - } - template - constexpr bool has_range = detail::has_Range::value; - template class AOWrapperIterator { @@ -334,7 +313,8 @@ namespace ngcore template auto Range(const T & x) - -> typename std::enable_if, decltype(Range_impl(x, std::is_integral()))>::type { + -> typename std::enable_if || !has_range, + decltype(Range_impl(x, std::is_integral()))>::type { return Range_impl(x, std::is_integral()); } diff --git a/libsrc/core/type_traits.hpp b/libsrc/core/type_traits.hpp index 3863940b..17da6253 100644 --- a/libsrc/core/type_traits.hpp +++ b/libsrc/core/type_traits.hpp @@ -28,6 +28,29 @@ namespace ngcore template constexpr bool is_any_pointer = is_any_pointer_impl::value; } // namespace detail + + + // Type trait to check if a class implements a 'range_type Range()' function + namespace detail + { + template + struct has_Range + { + private: + template + static constexpr auto check(T2*) -> + std::enable_if_t().Range()), void>, std::true_type> + { std::true_type(); } + template + static constexpr std::false_type check(...); + using type = decltype(check(nullptr)); // NOLINT + public: + NGCORE_API static constexpr bool value = type::value; + }; + } + template + constexpr bool has_range = detail::has_Range::value; + } // namespace ngcore #endif // NETGEN_CORE_TYPE_TRAITS_HPP