mirror of
https://github.com/ToruNiina/toml11.git
synced 2025-09-18 02:08:09 +08:00
Allow to build with intel c++ compiler
This commit is contained in:
@@ -9,7 +9,7 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
#if defined(_MSC_VER) || defined(__INTEL_COMPILER)
|
||||||
BOOST_AUTO_TEST_CASE(test_hard_example_unicode)
|
BOOST_AUTO_TEST_CASE(test_hard_example_unicode)
|
||||||
{
|
{
|
||||||
const auto data = toml::parse("toml/tests/hard_example_unicode.toml");
|
const auto data = toml::parse("toml/tests/hard_example_unicode.toml");
|
||||||
|
@@ -9,7 +9,7 @@ namespace toml
|
|||||||
struct exception : public std::exception
|
struct exception : public std::exception
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual ~exception() override = default;
|
virtual ~exception() noexcept override = default;
|
||||||
virtual const char* what() const noexcept override {return "";}
|
virtual const char* what() const noexcept override {return "";}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -18,7 +18,7 @@ struct syntax_error : public toml::exception
|
|||||||
public:
|
public:
|
||||||
explicit syntax_error(const std::string& what_arg) : what_(what_arg){}
|
explicit syntax_error(const std::string& what_arg) : what_(what_arg){}
|
||||||
explicit syntax_error(const char* what_arg) : what_(what_arg){}
|
explicit syntax_error(const char* what_arg) : what_(what_arg){}
|
||||||
virtual ~syntax_error() override = default;
|
virtual ~syntax_error() noexcept override = default;
|
||||||
virtual const char* what() const noexcept override {return what_.c_str();}
|
virtual const char* what() const noexcept override {return what_.c_str();}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
@@ -30,7 +30,7 @@ struct type_error : public toml::exception
|
|||||||
public:
|
public:
|
||||||
explicit type_error(const std::string& what_arg) : what_(what_arg){}
|
explicit type_error(const std::string& what_arg) : what_(what_arg){}
|
||||||
explicit type_error(const char* what_arg) : what_(what_arg){}
|
explicit type_error(const char* what_arg) : what_(what_arg){}
|
||||||
virtual ~type_error() override = default;
|
virtual ~type_error() noexcept override = default;
|
||||||
virtual const char* what() const noexcept override {return what_.c_str();}
|
virtual const char* what() const noexcept override {return what_.c_str();}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
@@ -42,7 +42,7 @@ struct internal_error : public toml::exception
|
|||||||
public:
|
public:
|
||||||
explicit internal_error(const std::string& what_arg) : what_(what_arg){}
|
explicit internal_error(const std::string& what_arg) : what_(what_arg){}
|
||||||
explicit internal_error(const char* what_arg) : what_(what_arg){}
|
explicit internal_error(const char* what_arg) : what_(what_arg){}
|
||||||
virtual ~internal_error() override = default;
|
virtual ~internal_error() noexcept override = default;
|
||||||
virtual const char* what() const noexcept override {return what_.c_str();}
|
virtual const char* what() const noexcept override {return what_.c_str();}
|
||||||
protected:
|
protected:
|
||||||
std::string what_;
|
std::string what_;
|
||||||
|
@@ -86,7 +86,10 @@ struct from_toml_tie_impl
|
|||||||
|
|
||||||
static void invoke(std::tuple<Ts& ...> tie, const toml::value& v)
|
static void invoke(std::tuple<Ts& ...> tie, const toml::value& v)
|
||||||
{
|
{
|
||||||
if(type_index == v.type())
|
// static_cast is needed because with intel c++ compiler, operator==
|
||||||
|
// is only defined when the two types are strictly equal, and type_index
|
||||||
|
// is const toml::value_t, while v.type() is toml::value_t.
|
||||||
|
if(static_cast<toml::value_t>(type_index) == v.type())
|
||||||
{
|
{
|
||||||
from_toml(std::get<index>(tie), v);
|
from_toml(std::get<index>(tie), v);
|
||||||
return;
|
return;
|
||||||
|
@@ -37,6 +37,12 @@ struct has_resize_method_impl
|
|||||||
template<typename T> static std::false_type check(...);
|
template<typename T> static std::false_type check(...);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/// 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
|
||||||
|
#ifdef __INTEL_COMPILER
|
||||||
|
#define decltype(...) std::enable_if<true, decltype(__VA_ARGS__)>::type
|
||||||
|
#endif
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
struct has_iterator : decltype(has_iterator_impl::check<T>(nullptr)){};
|
struct has_iterator : decltype(has_iterator_impl::check<T>(nullptr)){};
|
||||||
template<typename T>
|
template<typename T>
|
||||||
@@ -48,6 +54,10 @@ 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_resize_method : decltype(has_resize_method_impl::check<T>(nullptr)){};
|
||||||
|
|
||||||
|
#ifdef __INTEL_COMPILER
|
||||||
|
#undef decltype(...)
|
||||||
|
#endif
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
struct is_container : std::integral_constant<bool,
|
struct is_container : std::integral_constant<bool,
|
||||||
has_iterator<T>::value && has_value_type<T>::value>{};
|
has_iterator<T>::value && has_value_type<T>::value>{};
|
||||||
|
@@ -112,9 +112,20 @@ struct is_key_convertible_impl
|
|||||||
|
|
||||||
template<typename T> static std::false_type check(...);
|
template<typename T> static std::false_type check(...);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/// 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
|
||||||
|
#ifdef __INTEL_COMPILER
|
||||||
|
#define decltype(...) std::enable_if<true, decltype(__VA_ARGS__)>::type
|
||||||
|
#endif
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
struct is_key_convertible : decltype(is_key_convertible_impl::check<T>(nullptr)){};
|
struct is_key_convertible : decltype(is_key_convertible_impl::check<T>(nullptr)){};
|
||||||
|
|
||||||
|
#ifdef __INTEL_COMPILER
|
||||||
|
#undef decltype(...)
|
||||||
|
#endif
|
||||||
|
|
||||||
template<value_t t> struct toml_default_type{};
|
template<value_t t> struct toml_default_type{};
|
||||||
template<> struct toml_default_type<value_t::Boolean >{typedef Boolean type;};
|
template<> struct toml_default_type<value_t::Boolean >{typedef Boolean type;};
|
||||||
template<> struct toml_default_type<value_t::Integer >{typedef Integer type;};
|
template<> struct toml_default_type<value_t::Integer >{typedef Integer type;};
|
||||||
@@ -142,7 +153,7 @@ struct storage : public storage_base
|
|||||||
typedef T value_type;
|
typedef T value_type;
|
||||||
|
|
||||||
storage() = default;
|
storage() = default;
|
||||||
~storage() override = default;
|
~storage() noexcept override = default;
|
||||||
storage(storage const&) = default;
|
storage(storage const&) = default;
|
||||||
storage(storage&&) = default;
|
storage(storage&&) = default;
|
||||||
storage& operator=(storage const&) = default;
|
storage& operator=(storage const&) = default;
|
||||||
@@ -159,7 +170,7 @@ template<typename T>
|
|||||||
struct value_traits
|
struct value_traits
|
||||||
{
|
{
|
||||||
constexpr static value_t type_index = detail::check_type<T>();
|
constexpr static value_t type_index = detail::check_type<T>();
|
||||||
constexpr static bool is_toml_type = detail::is_valid(type_index);
|
constexpr static bool is_toml_type = detail::is_valid(detail::check_type<T>());
|
||||||
typedef typename detail::toml_default_type<type_index>::type type;
|
typedef typename detail::toml_default_type<type_index>::type type;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user