Merge branch 'master' of github.com:mpusz/units
This commit is contained in:
commit
8c9986dec8
5 files changed
+25
-41
No files matched your search
+7
-16
@@ -24,6 +24,7 @@
|
||||
|
||||
#include <units/bits/external/hacks.h>
|
||||
#include <type_traits>
|
||||
#include <utility>
|
||||
|
||||
namespace units {
|
||||
|
||||
@@ -58,32 +59,22 @@ template<class T, class U>
|
||||
using is_same = std::bool_constant<is_same_v<T, U>>;
|
||||
|
||||
// is_specialization_of
|
||||
namespace detail {
|
||||
|
||||
template<typename T, template<typename...> typename Type>
|
||||
inline constexpr bool is_specialization_of_impl = false;
|
||||
inline constexpr bool is_specialization_of = false;
|
||||
|
||||
template<typename... Params, template<typename...> typename Type>
|
||||
inline constexpr bool is_specialization_of_impl<Type<Params...>, Type> = true;
|
||||
|
||||
} // namespace detail
|
||||
|
||||
template<typename T, template<typename...> typename Type>
|
||||
inline constexpr bool is_specialization_of = detail::is_specialization_of_impl<T, Type>;
|
||||
inline constexpr bool is_specialization_of<Type<Params...>, Type> = true;
|
||||
|
||||
// is_derived_from_specialization_of
|
||||
namespace detail {
|
||||
|
||||
template<template<typename...> typename Type>
|
||||
struct is_derived_from_specialization_of_impl {
|
||||
template<typename... Params>
|
||||
static constexpr std::true_type check_base(const Type<Params...>&);
|
||||
static constexpr std::false_type check_base(...);
|
||||
};
|
||||
template<template<typename...> typename Type, typename... Params>
|
||||
void to_base_specialization_of(const volatile Type<Params...>*);
|
||||
|
||||
} // namespace detail
|
||||
|
||||
template<typename T, template<typename...> typename Type>
|
||||
inline constexpr bool is_derived_from_specialization_of = decltype(detail::is_derived_from_specialization_of_impl<Type>::check_base(std::declval<T>()))::value;
|
||||
// inline constexpr bool // TODO: Replace with concept when it works with MSVC
|
||||
concept is_derived_from_specialization_of = requires { detail::to_base_specialization_of<Type>(std::declval<const volatile T*>()); };
|
||||
|
||||
} // namespace units
|
||||
Reference in new issue
Block a user