mirror of
https://github.com/NGSolve/netgen.git
synced 2024-12-25 05:20:34 +05:00
index type can only be deduced from class, else it is size_t
This commit is contained in:
parent
22de6f2c56
commit
b12ef20fb7
@ -134,21 +134,18 @@ namespace ngcore
|
|||||||
private:
|
private:
|
||||||
template<typename T2>
|
template<typename T2>
|
||||||
static constexpr auto check(T2* t) -> typename T2::index_type { return *t; }
|
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...
|
static constexpr size_t check(...);
|
||||||
template<typename T2>
|
|
||||||
static constexpr auto check(T2* t) -> typename std::enable_if_t<std::is_integral_v<T>> {}
|
|
||||||
static constexpr auto check(...) -> decltype(std::declval<T>().Size())
|
|
||||||
{ return decltype(std::declval<T>().Size())(); }
|
|
||||||
public:
|
public:
|
||||||
using type = decltype(check((T*) nullptr)); // NOLINT
|
using type = decltype(check((T*) nullptr)); // NOLINT
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace detail
|
} // namespace detail
|
||||||
|
|
||||||
// Get index type of object. If object has a typedef index_type this type is returned
|
// Get index type of object. If object has a typedef index_type it is this type, else size_t
|
||||||
// else decltype(obj.Size()) is returned.
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
using index_type = typename detail::IndexTypeHelper<T>::type;
|
using index_type = typename detail::IndexTypeHelper<T>::type;
|
||||||
|
|
||||||
} // namespace ngcore
|
} // namespace ngcore
|
||||||
|
|
||||||
#endif // NETGEN_CORE_UTILS_HPP
|
#endif // NETGEN_CORE_UTILS_HPP
|
||||||
|
Loading…
Reference in New Issue
Block a user