mirror of
https://github.com/ToruNiina/toml11.git
synced 2025-09-18 02:08:09 +08:00
feat: add meta funcs, has_reserve/push_back_method
This commit is contained in:
@@ -43,17 +43,23 @@ struct has_mapped_type_impl
|
|||||||
template<typename T> static std::true_type check(typename T::mapped_type*);
|
template<typename T> static std::true_type check(typename T::mapped_type*);
|
||||||
template<typename T> static std::false_type check(...);
|
template<typename T> static std::false_type check(...);
|
||||||
};
|
};
|
||||||
struct has_resize_method_impl
|
struct has_reserve_method_impl
|
||||||
{
|
{
|
||||||
constexpr static std::size_t dummy=0;
|
|
||||||
template<typename T> static std::true_type check(decltype(std::declval<T>().resize(dummy))*);
|
|
||||||
template<typename T> static std::false_type check(...);
|
template<typename T> static std::false_type check(...);
|
||||||
|
template<typename T> static std::true_type check(
|
||||||
|
decltype(std::declval<T>().reserve(std::declval<std::size_t>()))*);
|
||||||
|
};
|
||||||
|
struct has_push_back_method_impl
|
||||||
|
{
|
||||||
|
template<typename T> static std::false_type check(...);
|
||||||
|
template<typename T> static std::true_type check(
|
||||||
|
decltype(std::declval<T>().push_back(std::declval<typename T::value_type>()))*);
|
||||||
};
|
};
|
||||||
|
|
||||||
struct is_comparable_impl
|
struct is_comparable_impl
|
||||||
{
|
{
|
||||||
template<typename T> static std::true_type check(decltype(std::declval<T>() < std::declval<T>())*);
|
|
||||||
template<typename T> static std::false_type check(...);
|
template<typename T> static std::false_type check(...);
|
||||||
|
template<typename T> static std::true_type check(
|
||||||
|
decltype(std::declval<T>() < std::declval<T>())*);
|
||||||
};
|
};
|
||||||
|
|
||||||
struct has_from_toml_method_impl
|
struct has_from_toml_method_impl
|
||||||
@@ -91,7 +97,9 @@ struct has_key_type : decltype(has_key_type_impl::check<T>(nullptr)){};
|
|||||||
template<typename T>
|
template<typename T>
|
||||||
struct has_mapped_type : decltype(has_mapped_type_impl::check<T>(nullptr)){};
|
struct has_mapped_type : decltype(has_mapped_type_impl::check<T>(nullptr)){};
|
||||||
template<typename T>
|
template<typename T>
|
||||||
struct has_resize_method : decltype(has_resize_method_impl::check<T>(nullptr)){};
|
struct has_reserve_method : decltype(has_reserve_method_impl::check<T>(nullptr)){};
|
||||||
|
template<typename T>
|
||||||
|
struct has_push_back_method : decltype(has_push_back_method_impl::check<T>(nullptr)){};
|
||||||
template<typename T>
|
template<typename T>
|
||||||
struct is_comparable : decltype(is_comparable_impl::check<T>(nullptr)){};
|
struct is_comparable : decltype(is_comparable_impl::check<T>(nullptr)){};
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user