diff --git a/tests/test_parse_unicode.cpp b/tests/test_parse_unicode.cpp index f2780a1..21f5d32 100644 --- a/tests/test_parse_unicode.cpp +++ b/tests/test_parse_unicode.cpp @@ -9,7 +9,7 @@ #include #include -#ifdef _MSC_VER +#if defined(_MSC_VER) || defined(__INTEL_COMPILER) BOOST_AUTO_TEST_CASE(test_hard_example_unicode) { const auto data = toml::parse("toml/tests/hard_example_unicode.toml"); diff --git a/toml/exception.hpp b/toml/exception.hpp index 7c9f221..87316b6 100644 --- a/toml/exception.hpp +++ b/toml/exception.hpp @@ -9,7 +9,7 @@ namespace toml struct exception : public std::exception { public: - virtual ~exception() override = default; + virtual ~exception() noexcept override = default; virtual const char* what() const noexcept override {return "";} }; @@ -18,7 +18,7 @@ struct syntax_error : public toml::exception public: explicit syntax_error(const std::string& 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();} protected: @@ -30,7 +30,7 @@ struct type_error : public toml::exception public: explicit type_error(const std::string& 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();} protected: @@ -42,7 +42,7 @@ struct internal_error : public toml::exception public: explicit internal_error(const std::string& 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();} protected: std::string what_; diff --git a/toml/from_toml.hpp b/toml/from_toml.hpp index 5e75fa8..8014110 100644 --- a/toml/from_toml.hpp +++ b/toml/from_toml.hpp @@ -86,7 +86,10 @@ struct from_toml_tie_impl static void invoke(std::tuple 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(type_index) == v.type()) { from_toml(std::get(tie), v); return; diff --git a/toml/traits.hpp b/toml/traits.hpp index 935f4e5..5e6e425 100644 --- a/toml/traits.hpp +++ b/toml/traits.hpp @@ -37,6 +37,12 @@ struct has_resize_method_impl template 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::type +#endif + template struct has_iterator : decltype(has_iterator_impl::check(nullptr)){}; template @@ -48,6 +54,10 @@ struct has_mapped_type : decltype(has_mapped_type_impl::check(nullptr)){}; template struct has_resize_method : decltype(has_resize_method_impl::check(nullptr)){}; +#ifdef __INTEL_COMPILER +#undef decltype(...) +#endif + template struct is_container : std::integral_constant::value && has_value_type::value>{}; diff --git a/toml/value.hpp b/toml/value.hpp index 3cd307a..d773c24 100644 --- a/toml/value.hpp +++ b/toml/value.hpp @@ -112,9 +112,20 @@ struct is_key_convertible_impl template 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::type +#endif + template struct is_key_convertible : decltype(is_key_convertible_impl::check(nullptr)){}; +#ifdef __INTEL_COMPILER +#undef decltype(...) +#endif + template struct toml_default_type{}; template<> struct toml_default_type{typedef Boolean type;}; template<> struct toml_default_type{typedef Integer type;}; @@ -142,7 +153,7 @@ struct storage : public storage_base typedef T value_type; storage() = default; - ~storage() override = default; + ~storage() noexcept override = default; storage(storage const&) = default; storage(storage&&) = default; storage& operator=(storage const&) = default; @@ -159,7 +170,7 @@ template struct value_traits { constexpr static value_t type_index = detail::check_type(); - constexpr static bool is_toml_type = detail::is_valid(type_index); + constexpr static bool is_toml_type = detail::is_valid(detail::check_type()); typedef typename detail::toml_default_type::type type; };