mirror of
https://github.com/ToruNiina/toml11.git
synced 2025-12-16 03:08:52 +08:00
fix: #159 Merge branch 'conversion-precedence'
This commit is contained in:
3
.github/workflows/main.yml
vendored
3
.github/workflows/main.yml
vendored
@@ -8,7 +8,7 @@ jobs:
|
|||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
# g++-4.8 and 4.9 are tested on Travis.CI.
|
# g++-4.8 and 4.9 are tested on Travis.CI.
|
||||||
compiler: ['g++-9', 'g++-8', 'g++-7', 'g++-6', 'g++-5']
|
compiler: ['g++-11', 'g++-10', 'g++-9', 'g++-8', 'g++-7', 'g++-6', 'g++-5']
|
||||||
standard: ['11', '14', '17', '20']
|
standard: ['11', '14', '17', '20']
|
||||||
exclude:
|
exclude:
|
||||||
- {compiler: 'g++-5', standard: '17'}
|
- {compiler: 'g++-5', standard: '17'}
|
||||||
@@ -59,6 +59,7 @@ jobs:
|
|||||||
- {compiler: '6.0', standard: '20'}
|
- {compiler: '6.0', standard: '20'}
|
||||||
- {compiler: '7', standard: '20'}
|
- {compiler: '7', standard: '20'}
|
||||||
- {compiler: '8', standard: '20'}
|
- {compiler: '8', standard: '20'}
|
||||||
|
- {compiler: '9', standard: '20'}
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v2
|
||||||
|
|||||||
25
toml/get.hpp
25
toml/get.hpp
@@ -255,16 +255,19 @@ get(const basic_value<C, M, V>&);
|
|||||||
|
|
||||||
// toml::from<T>::from_toml(v)
|
// toml::from<T>::from_toml(v)
|
||||||
template<typename T, typename C,
|
template<typename T, typename C,
|
||||||
template<typename ...> class M, template<typename ...> class V,
|
template<typename ...> class M, template<typename ...> class V>
|
||||||
std::size_t S = sizeof(::toml::from<T>)>
|
detail::enable_if_t<detail::has_specialized_from<T>::value, T>
|
||||||
T get(const basic_value<C, M, V>&);
|
get(const basic_value<C, M, V>&);
|
||||||
|
|
||||||
// T(const toml::value&) and T is not toml::basic_value
|
// T(const toml::value&) and T is not toml::basic_value,
|
||||||
|
// and it does not have `from<T>` nor `from_toml`.
|
||||||
template<typename T, typename C,
|
template<typename T, typename C,
|
||||||
template<typename ...> class M, template<typename ...> class V>
|
template<typename ...> class M, template<typename ...> class V>
|
||||||
detail::enable_if_t<detail::conjunction<
|
detail::enable_if_t<detail::conjunction<
|
||||||
detail::negation<detail::is_basic_value<T>>,
|
detail::negation<detail::is_basic_value<T>>,
|
||||||
std::is_constructible<T, const basic_value<C, M, V>&>
|
std::is_constructible<T, const basic_value<C, M, V>&>,
|
||||||
|
detail::negation<detail::has_from_toml_method<T, C, M, V>>,
|
||||||
|
detail::negation<detail::has_specialized_from<T>>
|
||||||
>::value, T>
|
>::value, T>
|
||||||
get(const basic_value<C, M, V>&);
|
get(const basic_value<C, M, V>&);
|
||||||
|
|
||||||
@@ -440,9 +443,9 @@ get(const basic_value<C, M, V>& v)
|
|||||||
return ud;
|
return ud;
|
||||||
}
|
}
|
||||||
template<typename T, typename C,
|
template<typename T, typename C,
|
||||||
template<typename ...> class M, template<typename ...> class V,
|
template<typename ...> class M, template<typename ...> class V>
|
||||||
std::size_t>
|
detail::enable_if_t<detail::has_specialized_from<T>::value, T>
|
||||||
T get(const basic_value<C, M, V>& v)
|
get(const basic_value<C, M, V>& v)
|
||||||
{
|
{
|
||||||
return ::toml::from<T>::from_toml(v);
|
return ::toml::from<T>::from_toml(v);
|
||||||
}
|
}
|
||||||
@@ -450,8 +453,10 @@ T get(const basic_value<C, M, V>& v)
|
|||||||
template<typename T, typename C,
|
template<typename T, typename C,
|
||||||
template<typename ...> class M, template<typename ...> class V>
|
template<typename ...> class M, template<typename ...> class V>
|
||||||
detail::enable_if_t<detail::conjunction<
|
detail::enable_if_t<detail::conjunction<
|
||||||
detail::negation<detail::is_basic_value<T>>,
|
detail::negation<detail::is_basic_value<T>>, // T is not a toml::value
|
||||||
std::is_constructible<T, const basic_value<C, M, V>&>
|
std::is_constructible<T, const basic_value<C, M, V>&>, // T is constructible from toml::value
|
||||||
|
detail::negation<detail::has_from_toml_method<T, C, M, V>>, // and T does not have T.from_toml(v);
|
||||||
|
detail::negation<detail::has_specialized_from<T>> // and T does not have toml::from<T>{};
|
||||||
>::value, T>
|
>::value, T>
|
||||||
get(const basic_value<C, M, V>& v)
|
get(const basic_value<C, M, V>& v)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -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, std::size_t S = sizeof(::toml::from<T>)>
|
||||||
|
static std::true_type check(::toml::from<T>*);
|
||||||
|
};
|
||||||
|
struct has_specialized_into_impl
|
||||||
|
{
|
||||||
|
template<typename T>
|
||||||
|
static std::false_type check(...);
|
||||||
|
template<typename T, std::size_t S = sizeof(::toml::into<T>)>
|
||||||
|
static std::true_type check(::toml::from<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