diff --git a/include/toml11/compat.hpp b/include/toml11/compat.hpp index 15a00af..41d3617 100644 --- a/include/toml11/compat.hpp +++ b/include/toml11/compat.hpp @@ -63,6 +63,8 @@ namespace toml { +inline namespace TOML11_INLINE_VERSION_NAMESPACE +{ namespace cxx { @@ -81,6 +83,7 @@ std::unique_ptr make_unique(Ts&& ... args) #endif // TOML11_HAS_STD_MAKE_UNIQUE } // cxx +} // TOML11_INLINE_VERSION_NAMESPACE } // toml // --------------------------------------------------------------------------- @@ -95,6 +98,8 @@ std::unique_ptr make_unique(Ts&& ... args) namespace toml { +inline namespace TOML11_INLINE_VERSION_NAMESPACE +{ namespace cxx { # if defined(TOML11_HAS_STD_MAKE_REVERSE_ITERATOR) @@ -112,6 +117,7 @@ std::reverse_iterator make_reverse_iterator(Iterator iter) #endif // TOML11_HAS_STD_MAKE_REVERSE_ITERATOR } // cxx +} // TOML11_INLINE_VERSION_NAMESPACE } // toml // --------------------------------------------------------------------------- @@ -126,6 +132,8 @@ std::reverse_iterator make_reverse_iterator(Iterator iter) namespace toml { +inline namespace TOML11_INLINE_VERSION_NAMESPACE +{ namespace cxx { #if defined(TOML11_HAS_STD_CLAMP) @@ -144,6 +152,7 @@ T clamp(const T& x, const T& low, const T& high) noexcept #endif // TOML11_HAS_STD_CLAMP } // cxx +} // TOML11_INLINE_VERSION_NAMESPACE } // toml // --------------------------------------------------------------------------- @@ -158,6 +167,8 @@ T clamp(const T& x, const T& low, const T& high) noexcept namespace toml { +inline namespace TOML11_INLINE_VERSION_NAMESPACE +{ namespace cxx { #if defined(TOML11_HAS_STD_BIT_CAST) @@ -183,6 +194,7 @@ U bit_cast(const T& x) noexcept #endif // TOML11_HAS_STD_BIT_CAST } // cxx +} // TOML11_INLINE_VERSION_NAMESPACE } // toml // --------------------------------------------------------------------------- @@ -198,6 +210,8 @@ U bit_cast(const T& x) noexcept namespace toml { +inline namespace TOML11_INLINE_VERSION_NAMESPACE +{ namespace cxx { #if defined(TOML11_HAS_STD_REMOVE_CVREF) @@ -220,6 +234,7 @@ using remove_cvref_t = typename remove_cvref::type; #endif // TOML11_HAS_STD_REMOVE_CVREF } // cxx +} // TOML11_INLINE_VERSION_NAMESPACE } // toml // --------------------------------------------------------------------------- @@ -235,6 +250,8 @@ using remove_cvref_t = typename remove_cvref::type; namespace toml { +inline namespace TOML11_INLINE_VERSION_NAMESPACE +{ namespace cxx { #if defined(TOML11_HAS_STD_CONJUNCTION) @@ -265,6 +282,7 @@ struct negation : std::integral_constant(T::value)>{}; #endif // TOML11_HAS_STD_CONJUNCTION } // cxx +} // TOML11_INLINE_VERSION_NAMESPACE } // toml // --------------------------------------------------------------------------- @@ -280,6 +298,8 @@ struct negation : std::integral_constant(T::value)>{}; namespace toml { +inline namespace TOML11_INLINE_VERSION_NAMESPACE +{ namespace cxx { #if defined(TOML11_HAS_STD_INTEGER_SEQUENCE) @@ -324,6 +344,7 @@ using make_index_sequence = typename index_sequence_maker::type; #endif // TOML11_HAS_STD_INTEGER_SEQUENCE } // cxx +} // TOML11_INLINE_VERSION_NAMESPACE } // toml // --------------------------------------------------------------------------- @@ -339,6 +360,8 @@ using make_index_sequence = typename index_sequence_maker::type; namespace toml { +inline namespace TOML11_INLINE_VERSION_NAMESPACE +{ namespace cxx { #if defined(TOML11_HAS_STD_ENABLE_IF_T) @@ -353,6 +376,7 @@ using enable_if_t = typename std::enable_if::type; #endif // TOML11_HAS_STD_ENABLE_IF_T } // cxx +} // TOML11_INLINE_VERSION_NAMESPACE } // toml // --------------------------------------------------------------------------- @@ -368,6 +392,8 @@ using enable_if_t = typename std::enable_if::type; namespace toml { +inline namespace TOML11_INLINE_VERSION_NAMESPACE +{ namespace cxx { #if defined(TOML11_HAS_STD_INVOKE_RESULT) @@ -384,6 +410,7 @@ using return_type_of_t = typename std::result_of::type; #endif // TOML11_HAS_STD_INVOKE_RESULT } // cxx +} // TOML11_INLINE_VERSION_NAMESPACE } // toml // --------------------------------------------------------------------------- @@ -399,6 +426,8 @@ using return_type_of_t = typename std::result_of::type; namespace toml { +inline namespace TOML11_INLINE_VERSION_NAMESPACE +{ namespace cxx { #if defined(TOML11_HAS_STD_VOID_T) @@ -413,6 +442,7 @@ using void_t = void; #endif // TOML11_HAS_STD_VOID_T } // cxx +} // TOML11_INLINE_VERSION_NAMESPACE } // toml // ---------------------------------------------------------------------------- @@ -457,6 +487,8 @@ using void_t = void; #include namespace toml { +inline namespace TOML11_INLINE_VERSION_NAMESPACE +{ namespace cxx { using source_location = std::source_location; @@ -477,11 +509,14 @@ inline std::string to_string(const source_location& loc) } } // cxx +} // TOML11_INLINE_VERSION_NAMESPACE } // toml #elif defined(TOML11_HAS_EXPERIMENTAL_SOURCE_LOCATION) #include namespace toml { +inline namespace TOML11_INLINE_VERSION_NAMESPACE +{ namespace cxx { using source_location = std::experimental::source_location; @@ -502,10 +537,13 @@ inline std::string to_string(const source_location& loc) } } // cxx +} // TOML11_INLINE_VERSION_NAMESPACE } // toml #elif defined(TOML11_HAS_BUILTIN_FILE_LINE) namespace toml { +inline namespace TOML11_INLINE_VERSION_NAMESPACE +{ namespace cxx { struct source_location @@ -546,10 +584,13 @@ inline std::string to_string(const source_location& loc) } } // cxx +} // TOML11_INLINE_VERSION_NAMESPACE } // toml #else // no builtin namespace toml { +inline namespace TOML11_INLINE_VERSION_NAMESPACE +{ namespace cxx { struct source_location @@ -562,6 +603,7 @@ inline std::string to_string(const source_location&) return std::string(""); } } // cxx +} // TOML11_INLINE_VERSION_NAMESPACE } // toml #endif // TOML11_HAS_STD_SOURCE_LOCATION @@ -586,6 +628,8 @@ inline std::string to_string(const source_location&) namespace toml { +inline namespace TOML11_INLINE_VERSION_NAMESPACE +{ namespace cxx { using std::optional; @@ -601,12 +645,15 @@ operator<<(std::basic_ostream& os, const std::nullopt_t&) } } // cxx +} // TOML11_INLINE_VERSION_NAMESPACE } // toml #else // TOML11_HAS_STD_OPTIONAL namespace toml { +inline namespace TOML11_INLINE_VERSION_NAMESPACE +{ namespace cxx { @@ -804,6 +851,7 @@ class optional }; }; } // cxx +} // TOML11_INLINE_VERSION_NAMESPACE } // toml #endif // TOML11_HAS_STD_OPTIONAL diff --git a/include/toml11/context.hpp b/include/toml11/context.hpp index cda038f..71c4b87 100644 --- a/include/toml11/context.hpp +++ b/include/toml11/context.hpp @@ -8,6 +8,8 @@ namespace toml { +inline namespace TOML11_INLINE_VERSION_NAMESPACE +{ namespace detail { @@ -50,11 +52,14 @@ class context }; } // detail +} // TOML11_INLINE_VERSION_NAMESPACE } // toml #if defined(TOML11_COMPILE_SOURCES) namespace toml { +inline namespace TOML11_INLINE_VERSION_NAMESPACE +{ struct type_config; struct ordered_type_config; namespace detail @@ -62,6 +67,7 @@ namespace detail extern template class context<::toml::type_config>; extern template class context<::toml::ordered_type_config>; } // detail +} // TOML11_INLINE_VERSION_NAMESPACE } // toml #endif // TOML11_COMPILE_SOURCES diff --git a/include/toml11/conversion.hpp b/include/toml11/conversion.hpp index 819a765..78814b1 100644 --- a/include/toml11/conversion.hpp +++ b/include/toml11/conversion.hpp @@ -4,6 +4,7 @@ #include "find.hpp" #include "from.hpp" // IWYU pragma: keep #include "into.hpp" // IWYU pragma: keep +#include "version.hpp" #if defined(TOML11_HAS_OPTIONAL) @@ -11,6 +12,8 @@ namespace toml { +inline namespace TOML11_INLINE_VERSION_NAMESPACE +{ namespace detail { @@ -57,12 +60,15 @@ void assign_member_variable_to_value(const T& obj, basic_value& v, const cha } } // detail +} // TOML11_INLINE_VERSION_NAMESPACE } // toml #else namespace toml { +inline namespace TOML11_INLINE_VERSION_NAMESPACE +{ namespace detail { @@ -79,6 +85,7 @@ void assign_member_variable_to_value(const T& obj, basic_value& v, const cha } } // detail +} // TOML11_INLINE_VERSION_NAMESPACE } // toml #endif // optional @@ -174,6 +181,7 @@ void assign_member_variable_to_value(const T& obj, basic_value& v, const cha #define TOML11_DEFINE_CONVERSION_NON_INTRUSIVE(NAME, ...)\ namespace toml { \ + namespace TOML11_INLINE_VERSION_NAMESPACE { \ template<> \ struct from \ { \ @@ -196,6 +204,7 @@ void assign_member_variable_to_value(const T& obj, basic_value& v, const cha return v; \ } \ }; \ + } /* TOML11_INLINE_VERSION_NAMESPACE */ \ } /* toml */ #endif// TOML11_WITHOUT_DEFINE_NON_INTRUSIVE diff --git a/include/toml11/exception.hpp b/include/toml11/exception.hpp index 7149eb3..e0c0aa8 100644 --- a/include/toml11/exception.hpp +++ b/include/toml11/exception.hpp @@ -3,8 +3,12 @@ #include +#include "version.hpp" + namespace toml { +inline namespace TOML11_INLINE_VERSION_NAMESPACE +{ struct exception : public std::exception { @@ -13,5 +17,6 @@ struct exception : public std::exception virtual const char* what() const noexcept override {return "";} }; +} // TOML11_INLINE_VERSION_NAMESPACE } // toml #endif // TOMl11_EXCEPTION_HPP diff --git a/include/toml11/find.hpp b/include/toml11/find.hpp index 428aaf6..a5c5be2 100644 --- a/include/toml11/find.hpp +++ b/include/toml11/find.hpp @@ -5,6 +5,7 @@ #include "get.hpp" #include "value.hpp" +#include "version.hpp" #if defined(TOML11_HAS_STRING_VIEW) #include @@ -12,6 +13,8 @@ namespace toml { +inline namespace TOML11_INLINE_VERSION_NAMESPACE +{ // ---------------------------------------------------------------------------- // find(value, key); @@ -584,5 +587,6 @@ find_or_default(const basic_value& v, K1&& k1, Ks&& ... keys) noexcept(std:: } } +} // TOML11_INLINE_VERSION_NAMESPACE } // toml #endif // TOML11_FIND_HPP diff --git a/include/toml11/from.hpp b/include/toml11/from.hpp index d2e0e13..72d7e1b 100644 --- a/include/toml11/from.hpp +++ b/include/toml11/from.hpp @@ -1,8 +1,11 @@ #ifndef TOML11_FROM_HPP #define TOML11_FROM_HPP +#include "version.hpp" namespace toml { +inline namespace TOML11_INLINE_VERSION_NAMESPACE +{ template struct from; @@ -13,5 +16,6 @@ struct from; // } // }; +} // TOML11_INLINE_VERSION_NAMESPACE } // toml #endif // TOML11_FROM_HPP diff --git a/include/toml11/fwd/color_fwd.hpp b/include/toml11/fwd/color_fwd.hpp index ed711c0..282ed8d 100644 --- a/include/toml11/fwd/color_fwd.hpp +++ b/include/toml11/fwd/color_fwd.hpp @@ -3,6 +3,8 @@ #include +#include "../version.hpp" + #ifdef TOML11_COLORIZE_ERROR_MESSAGE #define TOML11_ERROR_MESSAGE_COLORIZED true #else @@ -17,6 +19,8 @@ namespace toml { +inline namespace TOML11_INLINE_VERSION_NAMESPACE +{ namespace color { // put ANSI escape sequence to ostream @@ -84,5 +88,6 @@ inline bool should_color() } } // color +} // TOML11_INLINE_VERSION_NAMESPACE } // toml #endif // TOML11_COLOR_FWD_HPP diff --git a/include/toml11/fwd/comments_fwd.hpp b/include/toml11/fwd/comments_fwd.hpp index bbc9926..3fdeb1e 100644 --- a/include/toml11/fwd/comments_fwd.hpp +++ b/include/toml11/fwd/comments_fwd.hpp @@ -23,6 +23,8 @@ // error whenever you access to the element. namespace toml { +inline namespace TOML11_INLINE_VERSION_NAMESPACE +{ class discard_comments; // forward decl class preserve_comments @@ -447,5 +449,6 @@ inline void swap(const discard_comments&, const discard_comments&) noexcept {ret inline std::ostream& operator<<(std::ostream& os, const discard_comments&) {return os;} +} // TOML11_INLINE_VERSION_NAMESPACE } // toml11 #endif // TOML11_COMMENTS_FWD_HPP diff --git a/include/toml11/fwd/datetime_fwd.hpp b/include/toml11/fwd/datetime_fwd.hpp index 44616a1..f865256 100644 --- a/include/toml11/fwd/datetime_fwd.hpp +++ b/include/toml11/fwd/datetime_fwd.hpp @@ -9,8 +9,12 @@ #include #include +#include "../version.hpp" + namespace toml { +inline namespace TOML11_INLINE_VERSION_NAMESPACE +{ enum class month_t : std::uint8_t { @@ -257,5 +261,6 @@ std::ostream& operator<<(std::ostream& os, const offset_datetime& dt); std::string to_string(const offset_datetime& dt); -}//toml +} // TOML11_INLINE_VERSION_NAMESPACE +} // toml #endif // TOML11_DATETIME_FWD_HPP diff --git a/include/toml11/fwd/error_info_fwd.hpp b/include/toml11/fwd/error_info_fwd.hpp index 5b8600c..1d71c84 100644 --- a/include/toml11/fwd/error_info_fwd.hpp +++ b/include/toml11/fwd/error_info_fwd.hpp @@ -3,9 +3,12 @@ #include "../source_location.hpp" #include "../utility.hpp" +#include "../version.hpp" namespace toml { +inline namespace TOML11_INLINE_VERSION_NAMESPACE +{ // error info returned from parser. struct error_info @@ -93,5 +96,6 @@ std::string format_error(std::string title, std::ostream& operator<<(std::ostream& os, const error_info& e); +} // TOML11_INLINE_VERSION_NAMESPACE } // toml #endif // TOML11_ERROR_INFO_FWD_HPP diff --git a/include/toml11/fwd/format_fwd.hpp b/include/toml11/fwd/format_fwd.hpp index d478d96..3c0ea97 100644 --- a/include/toml11/fwd/format_fwd.hpp +++ b/include/toml11/fwd/format_fwd.hpp @@ -8,8 +8,12 @@ #include #include +#include "../version.hpp" + namespace toml { +inline namespace TOML11_INLINE_VERSION_NAMESPACE +{ // toml types with serialization info @@ -246,5 +250,6 @@ struct value_with_format }; } // detail +} // TOML11_INLINE_VERSION_NAMESPACE } // namespace toml #endif // TOML11_FORMAT_FWD_HPP diff --git a/include/toml11/fwd/literal_fwd.hpp b/include/toml11/fwd/literal_fwd.hpp index 82f62b7..8c1179f 100644 --- a/include/toml11/fwd/literal_fwd.hpp +++ b/include/toml11/fwd/literal_fwd.hpp @@ -7,6 +7,8 @@ namespace toml { +inline namespace TOML11_INLINE_VERSION_NAMESPACE +{ namespace detail { @@ -29,5 +31,6 @@ inline namespace toml_literals } // toml_literals } // literals +} // TOML11_INLINE_VERSION_NAMESPACE } // toml #endif // TOML11_LITERAL_FWD_HPP diff --git a/include/toml11/fwd/location_fwd.hpp b/include/toml11/fwd/location_fwd.hpp index 395b96c..7c1f89e 100644 --- a/include/toml11/fwd/location_fwd.hpp +++ b/include/toml11/fwd/location_fwd.hpp @@ -2,6 +2,7 @@ #define TOML11_LOCATION_FWD_HPP #include "../result.hpp" +#include "../version.hpp" #include #include @@ -9,6 +10,8 @@ namespace toml { +inline namespace TOML11_INLINE_VERSION_NAMESPACE +{ namespace detail { @@ -145,5 +148,6 @@ std::size_t count(const location& first, const location& last, const location::char_type& c); } // detail +} // TOML11_INLINE_VERSION_NAMESPACE } // toml #endif // TOML11_LOCATION_FWD_HPP diff --git a/include/toml11/fwd/region_fwd.hpp b/include/toml11/fwd/region_fwd.hpp index 04ce56f..6beed13 100644 --- a/include/toml11/fwd/region_fwd.hpp +++ b/include/toml11/fwd/region_fwd.hpp @@ -2,6 +2,7 @@ #define TOML11_REGION_FWD_HPP #include "../location.hpp" +#include "../version.hpp" #include #include @@ -10,6 +11,8 @@ namespace toml { +inline namespace TOML11_INLINE_VERSION_NAMESPACE +{ namespace detail { @@ -106,5 +109,6 @@ class region }; } // namespace detail +} // TOML11_INLINE_VERSION_NAMESPACE } // namespace toml #endif // TOML11_REGION_FWD_HPP diff --git a/include/toml11/fwd/scanner_fwd.hpp b/include/toml11/fwd/scanner_fwd.hpp index 562b6ad..770c0bb 100644 --- a/include/toml11/fwd/scanner_fwd.hpp +++ b/include/toml11/fwd/scanner_fwd.hpp @@ -2,6 +2,7 @@ #define TOML11_SCANNER_FWD_HPP #include "../region.hpp" +#include "../version.hpp" #include #include @@ -14,6 +15,8 @@ namespace toml { +inline namespace TOML11_INLINE_VERSION_NAMESPACE +{ namespace detail { @@ -362,5 +365,6 @@ class maybe final: public scanner_base }; } // detail +} // TOML11_INLINE_VERSION_NAMESPACE } // toml #endif // TOML11_SCANNER_FWD_HPP diff --git a/include/toml11/fwd/source_location_fwd.hpp b/include/toml11/fwd/source_location_fwd.hpp index 7022689..45be242 100644 --- a/include/toml11/fwd/source_location_fwd.hpp +++ b/include/toml11/fwd/source_location_fwd.hpp @@ -2,6 +2,7 @@ #define TOML11_SOURCE_LOCATION_FWD_HPP #include "../region.hpp" +#include "../version.hpp" #include #include @@ -9,6 +10,8 @@ namespace toml { +inline namespace TOML11_INLINE_VERSION_NAMESPACE +{ // // A struct to contain location in a toml file. @@ -144,5 +147,6 @@ std::string format_location( return detail::format_location_rec(lnw, f, loc, msg, tail...); } +} // TOML11_INLINE_VERSION_NAMESPACE } // toml #endif // TOML11_SOURCE_LOCATION_FWD_HPP diff --git a/include/toml11/fwd/syntax_fwd.hpp b/include/toml11/fwd/syntax_fwd.hpp index 567bf36..3e77bf1 100644 --- a/include/toml11/fwd/syntax_fwd.hpp +++ b/include/toml11/fwd/syntax_fwd.hpp @@ -3,9 +3,12 @@ #include "../scanner.hpp" #include "../spec.hpp" +#include "../version.hpp" namespace toml { +inline namespace TOML11_INLINE_VERSION_NAMESPACE +{ namespace detail { namespace syntax @@ -411,5 +414,6 @@ literal const& null_value(const spec&); } // namespace syntax } // namespace detail +} // TOML11_INLINE_VERSION_NAMESPACE } // namespace toml #endif // TOML11_SYNTAX_FWD_HPP diff --git a/include/toml11/fwd/value_t_fwd.hpp b/include/toml11/fwd/value_t_fwd.hpp index fddf843..ef0e232 100644 --- a/include/toml11/fwd/value_t_fwd.hpp +++ b/include/toml11/fwd/value_t_fwd.hpp @@ -3,6 +3,7 @@ #include "../compat.hpp" #include "../format.hpp" +#include "../version.hpp" #include #include @@ -12,6 +13,8 @@ namespace toml { +inline namespace TOML11_INLINE_VERSION_NAMESPACE +{ // forward decl template @@ -113,5 +116,6 @@ template struct is_exact_toml_type: is_exact_toml_type0< template struct is_not_toml_type : cxx::negation> {}; } // namespace detail +} // TOML11_INLINE_VERSION_NAMESPACE } // namespace toml #endif // TOML11_VALUE_T_FWD_HPP diff --git a/include/toml11/get.hpp b/include/toml11/get.hpp index 0704471..0450e53 100644 --- a/include/toml11/get.hpp +++ b/include/toml11/get.hpp @@ -6,6 +6,7 @@ #include "from.hpp" #include "types.hpp" #include "value.hpp" +#include "version.hpp" #if defined(TOML11_HAS_STRING_VIEW) #include @@ -13,6 +14,8 @@ namespace toml { +inline namespace TOML11_INLINE_VERSION_NAMESPACE +{ // ============================================================================ // T is toml::value; identity transformation. @@ -647,5 +650,6 @@ get_or(const basic_value& v, T&& opt) } } +} // TOML11_INLINE_VERSION_NAMESPACE } // toml #endif // TOML11_GET_HPP diff --git a/include/toml11/impl/color_impl.hpp b/include/toml11/impl/color_impl.hpp index 4215587..fa47f9b 100644 --- a/include/toml11/impl/color_impl.hpp +++ b/include/toml11/impl/color_impl.hpp @@ -8,6 +8,8 @@ namespace toml { +inline namespace TOML11_INLINE_VERSION_NAMESPACE +{ namespace color { // put ANSI escape sequence to ostream @@ -72,5 +74,6 @@ TOML11_INLINE std::ostream& white (std::ostream& os) } // ansi } // color +} // TOML11_INLINE_VERSION_NAMESPACE } // toml #endif // TOML11_COLOR_IMPL_HPP diff --git a/include/toml11/impl/comments_impl.hpp b/include/toml11/impl/comments_impl.hpp index 25023eb..a7dc82f 100644 --- a/include/toml11/impl/comments_impl.hpp +++ b/include/toml11/impl/comments_impl.hpp @@ -2,9 +2,12 @@ #define TOML11_COMMENTS_IMPL_HPP #include "../fwd/comments_fwd.hpp" // IWYU pragma: keep +#include "../version.hpp" namespace toml { +inline namespace TOML11_INLINE_VERSION_NAMESPACE +{ TOML11_INLINE bool operator==(const preserve_comments& lhs, const preserve_comments& rhs) {return lhs.comments == rhs.comments;} TOML11_INLINE bool operator!=(const preserve_comments& lhs, const preserve_comments& rhs) {return lhs.comments != rhs.comments;} @@ -42,5 +45,6 @@ TOML11_INLINE std::ostream& operator<<(std::ostream& os, const preserve_comments return os; } +} // TOML11_INLINE_VERSION_NAMESPACE } // toml11 #endif // TOML11_COMMENTS_IMPL_HPP diff --git a/include/toml11/impl/datetime_impl.hpp b/include/toml11/impl/datetime_impl.hpp index 50c0455..5d4745c 100644 --- a/include/toml11/impl/datetime_impl.hpp +++ b/include/toml11/impl/datetime_impl.hpp @@ -15,6 +15,8 @@ namespace toml { +inline namespace TOML11_INLINE_VERSION_NAMESPACE +{ // To avoid non-threadsafe std::localtime. In C11 (not C++11!), localtime_s is // provided in the absolutely same purpose, but C++11 is actually not compatible @@ -514,5 +516,6 @@ TOML11_INLINE std::string to_string(const offset_datetime& dt) return oss.str(); } -}//toml +} // TOML11_INLINE_VERSION_NAMESPACE +} // toml #endif // TOML11_DATETIME_IMPL_HPP diff --git a/include/toml11/impl/error_info_impl.hpp b/include/toml11/impl/error_info_impl.hpp index b87f477..b491a53 100644 --- a/include/toml11/impl/error_info_impl.hpp +++ b/include/toml11/impl/error_info_impl.hpp @@ -3,11 +3,14 @@ #include "../fwd/error_info_fwd.hpp" #include "../fwd/color_fwd.hpp" +#include "../version.hpp" #include namespace toml { +inline namespace TOML11_INLINE_VERSION_NAMESPACE +{ TOML11_INLINE std::string format_error(const std::string& errkind, const error_info& err) { @@ -71,5 +74,6 @@ TOML11_INLINE std::ostream& operator<<(std::ostream& os, const error_info& e) return os; } +} // TOML11_INLINE_VERSION_NAMESPACE } // toml #endif // TOML11_ERROR_INFO_IMPL_HPP diff --git a/include/toml11/impl/format_impl.hpp b/include/toml11/impl/format_impl.hpp index c4985fa..5e7c21a 100644 --- a/include/toml11/impl/format_impl.hpp +++ b/include/toml11/impl/format_impl.hpp @@ -9,6 +9,8 @@ namespace toml { +inline namespace TOML11_INLINE_VERSION_NAMESPACE +{ // toml types with serialization info @@ -293,5 +295,6 @@ TOML11_INLINE bool operator!=(const table_format_info& lhs, const table_format_i return !(lhs == rhs); } +} // TOML11_INLINE_VERSION_NAMESPACE } // namespace toml #endif // TOML11_FORMAT_IMPL_HPP diff --git a/include/toml11/impl/literal_impl.hpp b/include/toml11/impl/literal_impl.hpp index 067d4ed..dfd0382 100644 --- a/include/toml11/impl/literal_impl.hpp +++ b/include/toml11/impl/literal_impl.hpp @@ -4,9 +4,12 @@ #include "../fwd/literal_fwd.hpp" #include "../parser.hpp" #include "../syntax.hpp" +#include "../version.hpp" namespace toml { +inline namespace TOML11_INLINE_VERSION_NAMESPACE +{ namespace detail { @@ -170,5 +173,6 @@ operator"" _toml(const char8_t* str, std::size_t len) } // toml_literals } // literals +} // TOML11_INLINE_VERSION_NAMESPACE } // toml #endif // TOML11_LITERAL_IMPL_HPP diff --git a/include/toml11/impl/location_impl.hpp b/include/toml11/impl/location_impl.hpp index b996ab6..126070e 100644 --- a/include/toml11/impl/location_impl.hpp +++ b/include/toml11/impl/location_impl.hpp @@ -7,6 +7,8 @@ namespace toml { +inline namespace TOML11_INLINE_VERSION_NAMESPACE +{ namespace detail { @@ -205,5 +207,6 @@ count(const location& first, const location& last, const location::char_type& c) } } // detail +} // TOML11_INLINE_VERSION_NAMESPACE } // toml #endif // TOML11_LOCATION_HPP diff --git a/include/toml11/impl/region_impl.hpp b/include/toml11/impl/region_impl.hpp index 28242c8..603df52 100644 --- a/include/toml11/impl/region_impl.hpp +++ b/include/toml11/impl/region_impl.hpp @@ -3,6 +3,7 @@ #include "../fwd/region_fwd.hpp" #include "../utility.hpp" +#include "../version.hpp" #include #include @@ -13,6 +14,8 @@ namespace toml { +inline namespace TOML11_INLINE_VERSION_NAMESPACE +{ namespace detail { @@ -242,5 +245,6 @@ TOML11_INLINE std::vector> region::as_lines( } } // namespace detail +} // TOML11_INLINE_VERSION_NAMESPACE } // namespace toml #endif // TOML11_REGION_IMPL_HPP diff --git a/include/toml11/impl/scanner_impl.hpp b/include/toml11/impl/scanner_impl.hpp index 6ab011e..d79d849 100644 --- a/include/toml11/impl/scanner_impl.hpp +++ b/include/toml11/impl/scanner_impl.hpp @@ -3,9 +3,12 @@ #include "../fwd/scanner_fwd.hpp" #include "../utility.hpp" +#include "../version.hpp" namespace toml { +inline namespace TOML11_INLINE_VERSION_NAMESPACE +{ namespace detail { @@ -468,5 +471,6 @@ TOML11_INLINE std::string maybe::name() const } } // detail +} // TOML11_INLINE_VERSION_NAMESPACE } // toml #endif // TOML11_SCANNER_IMPL_HPP diff --git a/include/toml11/impl/source_location_impl.hpp b/include/toml11/impl/source_location_impl.hpp index 3ecf2ad..8c71855 100644 --- a/include/toml11/impl/source_location_impl.hpp +++ b/include/toml11/impl/source_location_impl.hpp @@ -5,6 +5,7 @@ #include "../color.hpp" #include "../utility.hpp" +#include "../version.hpp" #include #include @@ -15,6 +16,8 @@ namespace toml { +inline namespace TOML11_INLINE_VERSION_NAMESPACE +{ TOML11_INLINE source_location::source_location(const detail::region& r) : is_ok_(false), @@ -207,5 +210,6 @@ TOML11_INLINE std::string format_location_impl(const std::size_t lnw, } } // namespace detail +} // TOML11_INLINE_VERSION_NAMESPACE } // toml #endif // TOML11_SOURCE_LOCATION_IMPL_HPP diff --git a/include/toml11/impl/syntax_impl.hpp b/include/toml11/impl/syntax_impl.hpp index 2dc768a..4502308 100644 --- a/include/toml11/impl/syntax_impl.hpp +++ b/include/toml11/impl/syntax_impl.hpp @@ -4,9 +4,12 @@ #include "../fwd/syntax_fwd.hpp" #include "../scanner.hpp" #include "../spec.hpp" +#include "../version.hpp" namespace toml { +inline namespace TOML11_INLINE_VERSION_NAMESPACE +{ namespace detail { namespace syntax @@ -885,5 +888,6 @@ TOML11_INLINE literal const& null_value(const spec&) } // namespace syntax } // namespace detail +} // TOML11_INLINE_VERSION_NAMESPACE } // namespace toml #endif // TOML11_SYNTAX_IMPL_HPP diff --git a/include/toml11/impl/value_t_impl.hpp b/include/toml11/impl/value_t_impl.hpp index 784dc8b..ba96de7 100644 --- a/include/toml11/impl/value_t_impl.hpp +++ b/include/toml11/impl/value_t_impl.hpp @@ -2,6 +2,7 @@ #define TOML11_VALUE_T_IMPL_HPP #include "../fwd/value_t_fwd.hpp" +#include "../version.hpp" #include #include @@ -9,6 +10,8 @@ namespace toml { +inline namespace TOML11_INLINE_VERSION_NAMESPACE +{ TOML11_INLINE std::ostream& operator<<(std::ostream& os, value_t t) { @@ -36,5 +39,6 @@ TOML11_INLINE std::string to_string(value_t t) return oss.str(); } +} //TOML11_INLINE_VERSION_NAMESPACE } // namespace toml #endif // TOML11_VALUE_T_IMPL_HPP diff --git a/include/toml11/into.hpp b/include/toml11/into.hpp index 86a0020..035986d 100644 --- a/include/toml11/into.hpp +++ b/include/toml11/into.hpp @@ -1,8 +1,11 @@ #ifndef TOML11_INTO_HPP #define TOML11_INTO_HPP +#include "version.hpp" namespace toml { +inline namespace TOML11_INLINE_VERSION_NAMESPACE +{ template struct into; @@ -13,5 +16,6 @@ struct into; // } // }; +} // TOML11_INLINE_VERSION_NAMESPACE } // toml #endif // TOML11_INTO_HPP diff --git a/include/toml11/ordered_map.hpp b/include/toml11/ordered_map.hpp index d296187..b7028d9 100644 --- a/include/toml11/ordered_map.hpp +++ b/include/toml11/ordered_map.hpp @@ -6,8 +6,12 @@ #include #include +#include "version.hpp" + namespace toml { +inline namespace TOML11_INLINE_VERSION_NAMESPACE +{ namespace detail { @@ -193,17 +197,17 @@ class ordered_map : detail::ordered_map_ebo_container { return container_.erase(pos); } - + iterator erase(const_iterator pos) { return container_.erase(pos); } - + iterator erase(const_iterator first, const_iterator last) { return container_.erase(first, last); } - + size_type erase(const key_type& key) { auto it = this->find(key); @@ -287,5 +291,6 @@ void swap(ordered_map& lhs, ordered_map& rhs) } +} // TOML11_INLINE_VERSION_NAMESPACE } // toml #endif // TOML11_ORDERED_MAP_HPP diff --git a/include/toml11/parser.hpp b/include/toml11/parser.hpp index 83ef3d0..8aeaa93 100644 --- a/include/toml11/parser.hpp +++ b/include/toml11/parser.hpp @@ -10,6 +10,7 @@ #include "skip.hpp" #include "syntax.hpp" #include "value.hpp" +#include "version.hpp" #include #include @@ -23,6 +24,8 @@ namespace toml { +inline namespace TOML11_INLINE_VERSION_NAMESPACE +{ struct syntax_error final : public ::toml::exception { @@ -3786,11 +3789,14 @@ parse(FILE* fp, std::string filename, spec s = spec::default_version()) } } +} // TOML11_INLINE_VERSION_NAMESPACE } // namespace toml #if defined(TOML11_COMPILE_SOURCES) namespace toml { +inline namespace TOML11_INLINE_VERSION_NAMESPACE +{ struct type_config; struct ordered_type_config; @@ -3825,6 +3831,7 @@ extern template cxx::enable_if_t::value, basic_value > parse (const std::filesystem::path&, spec); #endif // filesystem +} // TOML11_INLINE_VERSION_NAMESPACE } // toml #endif // TOML11_COMPILE_SOURCES diff --git a/include/toml11/result.hpp b/include/toml11/result.hpp index f16959e..5efbe12 100644 --- a/include/toml11/result.hpp +++ b/include/toml11/result.hpp @@ -3,6 +3,7 @@ #include "compat.hpp" #include "exception.hpp" +#include "version.hpp" #include #include @@ -13,6 +14,8 @@ namespace toml { +inline namespace TOML11_INLINE_VERSION_NAMESPACE +{ struct bad_result_access final : public ::toml::exception { @@ -482,5 +485,6 @@ inline failure err() noexcept return failure(detail::none_t{}); } +} // TOML11_INLINE_VERSION_NAMESPACE } // toml #endif // TOML11_RESULT_HPP diff --git a/include/toml11/serializer.hpp b/include/toml11/serializer.hpp index a3f148e..e8dc597 100644 --- a/include/toml11/serializer.hpp +++ b/include/toml11/serializer.hpp @@ -10,6 +10,7 @@ #include "types.hpp" #include "utility.hpp" #include "value.hpp" +#include "version.hpp" #include #include @@ -20,6 +21,8 @@ namespace toml { +inline namespace TOML11_INLINE_VERSION_NAMESPACE +{ struct serialization_error final : public ::toml::exception { @@ -1233,11 +1236,14 @@ std::ostream& operator<<(std::ostream& os, const basic_value& v) return os; } +} // TOML11_INLINE_VERSION_NAMESPACE } // toml #if defined(TOML11_COMPILE_SOURCES) namespace toml { +inline namespace TOML11_INLINE_VERSION_NAMESPACE +{ struct type_config; struct ordered_type_config; @@ -1268,6 +1274,7 @@ namespace detail extern template class serializer<::toml::type_config>; extern template class serializer<::toml::ordered_type_config>; } // detail +} // TOML11_INLINE_VERSION_NAMESPACE } // toml #endif // TOML11_COMPILE_SOURCES diff --git a/include/toml11/skip.hpp b/include/toml11/skip.hpp index 5a3b1b7..17a21f7 100644 --- a/include/toml11/skip.hpp +++ b/include/toml11/skip.hpp @@ -6,11 +6,14 @@ #include "scanner.hpp" #include "syntax.hpp" #include "types.hpp" +#include "version.hpp" #include namespace toml { +inline namespace TOML11_INLINE_VERSION_NAMESPACE +{ namespace detail { @@ -353,11 +356,14 @@ void skip_until_next_table(location& loc, const context& ctx) } } // namespace detail +} // TOML11_INLINE_VERSION_NAMESPACE } // namespace toml #if defined(TOML11_COMPILE_SOURCES) namespace toml { +inline namespace TOML11_INLINE_VERSION_NAMESPACE +{ struct type_config; struct ordered_type_config; @@ -386,6 +392,7 @@ extern template void skip_key_value_pair (location& extern template void skip_until_next_table (location& loc, const context&); } // detail +} // TOML11_INLINE_VERSION_NAMESPACE } // toml #endif // TOML11_COMPILE_SOURCES diff --git a/include/toml11/spec.hpp b/include/toml11/spec.hpp index df9f3d7..15f5e46 100644 --- a/include/toml11/spec.hpp +++ b/include/toml11/spec.hpp @@ -9,8 +9,12 @@ #include +#include "version.hpp" + namespace toml { +inline namespace TOML11_INLINE_VERSION_NAMESPACE +{ struct semantic_version { @@ -165,5 +169,6 @@ inline bool operator>=(const spec& lhs, const spec& rhs) noexcept return detail::to_tuple(lhs) >= detail::to_tuple(rhs); } +} // TOML11_INLINE_VERSION_NAMESPACE } // namespace toml #endif // TOML11_SPEC_HPP diff --git a/include/toml11/storage.hpp b/include/toml11/storage.hpp index b63e24f..7b1e70d 100644 --- a/include/toml11/storage.hpp +++ b/include/toml11/storage.hpp @@ -2,9 +2,12 @@ #define TOML11_STORAGE_HPP #include "compat.hpp" +#include "version.hpp" namespace toml { +inline namespace TOML11_INLINE_VERSION_NAMESPACE +{ namespace detail { @@ -45,5 +48,6 @@ struct storage }; } // detail +} // TOML11_INLINE_VERSION_NAMESPACE } // toml #endif // TOML11_STORAGE_HPP diff --git a/include/toml11/traits.hpp b/include/toml11/traits.hpp index 27ef1d4..eaa99fd 100644 --- a/include/toml11/traits.hpp +++ b/include/toml11/traits.hpp @@ -4,6 +4,7 @@ #include "from.hpp" #include "into.hpp" #include "compat.hpp" +#include "version.hpp" #include #include @@ -24,6 +25,8 @@ namespace toml { +inline namespace TOML11_INLINE_VERSION_NAMESPACE +{ template class basic_value; @@ -262,5 +265,6 @@ template using is_basic_value = is_basic_value_impl>; }// detail -}//toml +} // TOML11_INLINE_VERSION_NAMESPACE +} // toml #endif // TOML11_TRAITS_HPP diff --git a/include/toml11/types.hpp b/include/toml11/types.hpp index 6d59b99..8c43a10 100644 --- a/include/toml11/types.hpp +++ b/include/toml11/types.hpp @@ -7,6 +7,7 @@ #include "format.hpp" #include "ordered_map.hpp" #include "value.hpp" +#include "version.hpp" #include #include @@ -20,6 +21,8 @@ namespace toml { +inline namespace TOML11_INLINE_VERSION_NAMESPACE +{ // forward decl template @@ -361,13 +364,17 @@ using is_type_config = cxx::conjunction< >; } // namespace detail +} // TOML11_INLINE_VERSION_NAMESPACE } // namespace toml #if defined(TOML11_COMPILE_SOURCES) namespace toml { +inline namespace TOML11_INLINE_VERSION_NAMESPACE +{ extern template class basic_value; extern template class basic_value; +} // TOML11_INLINE_VERSION_NAMESPACE } // toml #endif // TOML11_COMPILE_SOURCES diff --git a/include/toml11/utility.hpp b/include/toml11/utility.hpp index 9e30ccb..4f5ccb7 100644 --- a/include/toml11/utility.hpp +++ b/include/toml11/utility.hpp @@ -3,6 +3,7 @@ #include "result.hpp" #include "traits.hpp" +#include "version.hpp" #include #include @@ -13,6 +14,8 @@ namespace toml { +inline namespace TOML11_INLINE_VERSION_NAMESPACE +{ namespace detail { @@ -166,5 +169,6 @@ string_conv(const char (&s)[N]) } } // namespace detail +} // TOML11_INLINE_VERSION_NAMESPACE } // namespace toml #endif // TOML11_UTILITY_HPP diff --git a/include/toml11/value.hpp b/include/toml11/value.hpp index 7053f35..8b446a7 100644 --- a/include/toml11/value.hpp +++ b/include/toml11/value.hpp @@ -25,6 +25,8 @@ namespace toml { +inline namespace TOML11_INLINE_VERSION_NAMESPACE +{ template class basic_value; @@ -2506,5 +2508,6 @@ void unset_access_flag_recursively(basic_value& v) #endif } // namespace detail +} // TOML11_INLINE_VERSION_NAMESPACE } // namespace toml #endif // TOML11_VALUE_HPP diff --git a/include/toml11/version.hpp b/include/toml11/version.hpp index f1d7608..314c25b 100644 --- a/include/toml11/version.hpp +++ b/include/toml11/version.hpp @@ -9,6 +9,25 @@ # error "__cplusplus is not defined" #endif +/* + * Defines a name for an inline namespace that includes the current version + * number. This becomes necessary if multiple software packages use toml11 as an + * internal build-time dependency, since multiple packages will in general not + * use the same version of toml11. An inline namespace with a version number + * ensures that the symbols emitted by compiling toml11 into downstream + * applications will be distinguished by the specific used version of toml11, + * making it possible to link multiple packages that internally use toml11 in + * different versions. + */ +#define TOML11_CONCAT(a, b, c, d, e, f) a##b##c##d##e##f + +#define TOML11_GENERATE_INLINE_VERSION_NAMESPACE(major, minor, patch) \ + TOML11_CONCAT(toml11_, major, _, minor, _, patch) + +#define TOML11_INLINE_VERSION_NAMESPACE \ + TOML11_GENERATE_INLINE_VERSION_NAMESPACE( \ + TOML11_VERSION_MAJOR, TOML11_VERSION_MINOR, TOML11_VERSION_PATCH) + // Since MSVC does not define `__cplusplus` correctly unless you pass // `/Zc:__cplusplus` when compiling, the workaround macros are added. // @@ -91,6 +110,8 @@ namespace toml { +inline namespace TOML11_INLINE_VERSION_NAMESPACE +{ inline const char* license_notice() noexcept { @@ -117,5 +138,6 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.)"; } +} // TOML11_INLINE_VERSION_NAMESPACE } // toml #endif // TOML11_VERSION_HPP diff --git a/include/toml11/visit.hpp b/include/toml11/visit.hpp index 715b403..c12af91 100644 --- a/include/toml11/visit.hpp +++ b/include/toml11/visit.hpp @@ -4,9 +4,12 @@ #include "exception.hpp" #include "traits.hpp" #include "value.hpp" +#include "version.hpp" namespace toml { +inline namespace TOML11_INLINE_VERSION_NAMESPACE +{ namespace detail { @@ -132,5 +135,6 @@ visit(Visitor&& visitor, Args&& ... args) return detail::visit_impl(std::forward(visitor), std::forward(args)...); } +} // TOML11_INLINE_VERSION_NAMESPACE } // toml #endif // TOML11_VISIT_HPP diff --git a/include/toml_fwd.hpp b/include/toml_fwd.hpp index 3ba77ff..6799808 100644 --- a/include/toml_fwd.hpp +++ b/include/toml_fwd.hpp @@ -19,6 +19,8 @@ namespace toml { +inline namespace TOML11_INLINE_VERSION_NAMESPACE +{ class discard_comments; class preserve_comments; @@ -84,5 +86,6 @@ using ordered_value = basic_value; enum class value_t : std::uint8_t; +} // TOML11_INLINE_VERSION_NAMESPACE } // toml #endif// TOML11_TOML_HPP diff --git a/src/context.cpp b/src/context.cpp index aa7ab8a..92d4729 100644 --- a/src/context.cpp +++ b/src/context.cpp @@ -1,5 +1,6 @@ #include #include +#include #if ! defined(TOML11_COMPILE_SOURCES) #error "Define `TOML11_COMPILE_SOURCES` before compiling source code!" @@ -7,9 +8,12 @@ namespace toml { +inline namespace TOML11_INLINE_VERSION_NAMESPACE +{ namespace detail { template class context<::toml::type_config>; template class context<::toml::ordered_type_config>; } // detail +} // TOML11_INLINE_VERSION_NAMESPACE } // toml diff --git a/src/parser.cpp b/src/parser.cpp index adb21cc..dd0b665 100644 --- a/src/parser.cpp +++ b/src/parser.cpp @@ -1,5 +1,6 @@ #include #include +#include #if ! defined(TOML11_COMPILE_SOURCES) #error "Define `TOML11_COMPILE_SOURCES` before compiling source code!" @@ -7,6 +8,8 @@ namespace toml { +inline namespace TOML11_INLINE_VERSION_NAMESPACE +{ template result, std::vector> try_parse(std::vector, std::string, spec); template result, std::vector> try_parse(std::istream&, std::string, spec); @@ -39,4 +42,5 @@ template cxx::enable_if_t::value, basic_value > parse (const std::filesystem::path&, spec); #endif // filesystem +} // TOML11_INLINE_VERSION_NAMESPACE } // toml diff --git a/src/serializer.cpp b/src/serializer.cpp index 5dcaffe..cf8505e 100644 --- a/src/serializer.cpp +++ b/src/serializer.cpp @@ -1,5 +1,6 @@ #include #include +#include #if ! defined(TOML11_COMPILE_SOURCES) #error "Define `TOML11_COMPILE_SOURCES` before compiling source code!" @@ -7,6 +8,8 @@ namespace toml { +inline namespace TOML11_INLINE_VERSION_NAMESPACE +{ struct type_config; struct ordered_type_config; @@ -37,4 +40,5 @@ namespace detail template class serializer<::toml::type_config>; template class serializer<::toml::ordered_type_config>; } // detail +} // TOML11_INLINE_VERSION_NAMESPACE } // toml diff --git a/src/skip.cpp b/src/skip.cpp index 7e5531b..9563660 100644 --- a/src/skip.cpp +++ b/src/skip.cpp @@ -1,6 +1,7 @@ #include #include #include +#include #if ! defined(TOML11_COMPILE_SOURCES) #error "Define `TOML11_COMPILE_SOURCES` before compiling source code!" @@ -8,6 +9,8 @@ namespace toml { +inline namespace TOML11_INLINE_VERSION_NAMESPACE +{ namespace detail { @@ -34,4 +37,5 @@ template void skip_key_value_pair (location& loc, co template void skip_until_next_table (location& loc, const context&); } // detail +} // TOML11_INLINE_VERSION_NAMESPACE } // toml diff --git a/src/types.cpp b/src/types.cpp index d70a510..fbb7254 100644 --- a/src/types.cpp +++ b/src/types.cpp @@ -1,5 +1,6 @@ #include #include +#include #if ! defined(TOML11_COMPILE_SOURCES) #error "Define `TOML11_COMPILE_SOURCES` before compiling source code!" @@ -7,6 +8,9 @@ namespace toml { +inline namespace TOML11_INLINE_VERSION_NAMESPACE +{ template class basic_value; template class basic_value; +} // TOML11_INLINE_VERSION_NAMESPACE } // toml