From b12ef20fb7a45f889729ec7c3bdf0688aafacae5 Mon Sep 17 00:00:00 2001 From: Christopher Lackner Date: Wed, 21 Aug 2019 11:24:37 +0200 Subject: [PATCH] index type can only be deduced from class, else it is size_t --- libsrc/core/utils.hpp | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/libsrc/core/utils.hpp b/libsrc/core/utils.hpp index f6df8c9e..84d1dade 100644 --- a/libsrc/core/utils.hpp +++ b/libsrc/core/utils.hpp @@ -134,21 +134,18 @@ namespace ngcore private: template static constexpr auto check(T2* t) -> typename T2::index_type { return *t; } - // this function is needed for visual because it seems to not lazy evaluate template arguments... - template - static constexpr auto check(T2* t) -> typename std::enable_if_t> {} - static constexpr auto check(...) -> decltype(std::declval().Size()) - { return decltype(std::declval().Size())(); } + static constexpr size_t check(...); + public: using type = decltype(check((T*) nullptr)); // NOLINT }; } // namespace detail - // Get index type of object. If object has a typedef index_type this type is returned - // else decltype(obj.Size()) is returned. + // Get index type of object. If object has a typedef index_type it is this type, else size_t template using index_type = typename detail::IndexTypeHelper::type; + } // namespace ngcore #endif // NETGEN_CORE_UTILS_HPP