mirror of
https://github.com/ToruNiina/toml11.git
synced 2025-09-19 03:18:09 +08:00
feat: add detail::has_specialization_from/into
This commit is contained in:
@@ -2,6 +2,10 @@
|
|||||||
// Distributed under the MIT License.
|
// Distributed under the MIT License.
|
||||||
#ifndef TOML11_TRAITS_HPP
|
#ifndef TOML11_TRAITS_HPP
|
||||||
#define TOML11_TRAITS_HPP
|
#define TOML11_TRAITS_HPP
|
||||||
|
|
||||||
|
#include "from.hpp"
|
||||||
|
#include "into.hpp"
|
||||||
|
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
#include <forward_list>
|
#include <forward_list>
|
||||||
#include <string>
|
#include <string>
|
||||||
@@ -84,6 +88,22 @@ struct has_into_toml_method_impl
|
|||||||
static std::false_type check(...);
|
static std::false_type check(...);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct has_specialized_from_impl
|
||||||
|
{
|
||||||
|
template<typename T>
|
||||||
|
static std::false_type check(...);
|
||||||
|
template<typename T>
|
||||||
|
static std::true_type check(std::nullptr_t, std::size_t S = sizeof(::toml::from<T>));
|
||||||
|
};
|
||||||
|
struct has_specialized_into_impl
|
||||||
|
{
|
||||||
|
template<typename T>
|
||||||
|
static std::false_type check(...);
|
||||||
|
template<typename T>
|
||||||
|
static std::true_type check(std::nullptr_t, std::size_t S = sizeof(::toml::into<T>));
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
/// Intel C++ compiler can not use decltype in parent class declaration, here
|
/// Intel C++ compiler can not use decltype in parent class declaration, here
|
||||||
/// is a hack to work around it. https://stackoverflow.com/a/23953090/4692076
|
/// is a hack to work around it. https://stackoverflow.com/a/23953090/4692076
|
||||||
#ifdef __INTEL_COMPILER
|
#ifdef __INTEL_COMPILER
|
||||||
@@ -114,6 +134,11 @@ template<typename T>
|
|||||||
struct has_into_toml_method
|
struct has_into_toml_method
|
||||||
: decltype(has_into_toml_method_impl::check<T>(nullptr)){};
|
: decltype(has_into_toml_method_impl::check<T>(nullptr)){};
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
struct has_specialized_from : decltype(has_specialized_from_impl::check<T>(nullptr)){};
|
||||||
|
template<typename T>
|
||||||
|
struct has_specialized_into : decltype(has_specialized_into_impl::check<T>(nullptr)){};
|
||||||
|
|
||||||
#ifdef __INTEL_COMPILER
|
#ifdef __INTEL_COMPILER
|
||||||
#undef decltype
|
#undef decltype
|
||||||
#endif
|
#endif
|
||||||
|
Reference in New Issue
Block a user