diff --git a/docs/Doxyfile b/docs/Doxyfile
index 162f962..931f816 100644
--- a/docs/Doxyfile
+++ b/docs/Doxyfile
@@ -39,25 +39,26 @@ MULTILINE_CPP_IS_BRIEF = NO
INHERIT_DOCS = YES
SEPARATE_MEMBER_PAGES = NO
TAB_SIZE = 4
-ALIASES = \
- "cpp=@code{.cpp}" \
- "ecpp=@endcode" \
- "out=@code{.shell-session}" \
- "eout=@endcode" \
- "bash=@code{.sh}" \
- "ebash=@endcode" \
- "detail=@details" \
- "gh{1}=\1"\
- "gh2{2}=\2"\
- "m_div{1}=@xmlonly@endxmlonly" \
- "m_enddiv=@xmlonly@endxmlonly" \
- "m_span{1}=@xmlonly@endxmlonly" \
- "m_endspan=@xmlonly@endxmlonly" \
- "m_class{1}=@xmlonly@endxmlonly" \
- "m_footernavigation=@xmlonly@endxmlonly" \
- "m_examplenavigation{2}=@xmlonly@endxmlonly" \
- "m_keywords{1}=@xmlonly@endxmlonly" \
- "m_keyword{3}=@xmlonly@endxmlonly" \
+ALIASES = \
+ "cpp=@code{.cpp}" \
+ "ecpp=@endcode" \
+ "out=@code{.shell-session}" \
+ "eout=@endcode" \
+ "bash=@code{.sh}" \
+ "ebash=@endcode" \
+ "detail=@details" \
+ "gh{1}=\1" \
+ "gh2{2}=\2" \
+ "godbolt{1}=Try this code on Compiler Explorer" \
+ "m_div{1}=@xmlonly@endxmlonly" \
+ "m_enddiv=@xmlonly@endxmlonly" \
+ "m_span{1}=@xmlonly@endxmlonly" \
+ "m_endspan=@xmlonly@endxmlonly" \
+ "m_class{1}=@xmlonly@endxmlonly" \
+ "m_footernavigation=@xmlonly@endxmlonly" \
+ "m_examplenavigation{2}=@xmlonly@endxmlonly" \
+ "m_keywords{1}=@xmlonly@endxmlonly" \
+ "m_keyword{3}=@xmlonly@endxmlonly" \
"m_enum_values_as_keywords=@xmlonly@endxmlonly"
TCL_SUBST =
OPTIMIZE_OUTPUT_FOR_C = NO
@@ -316,7 +317,7 @@ PREDEFINED = TOML_DOXYGEN=1 \
TOML_API= \
TOML_ABI_NAMESPACE_START(x)= \
TOML_ABI_NAMESPACE_END= \
- TOML_GNU_ATTR(...)= \
+ TOML_ATTR(...)= \
TOML_PUSH_WARNINGS= \
TOML_DISABLE_SWITCH_WARNINGS= \
TOML_DISABLE_INIT_WARNINGS= \
@@ -324,6 +325,7 @@ PREDEFINED = TOML_DOXYGEN=1 \
TOML_DISABLE_PADDING_WARNINGS= \
TOML_DISABLE_FLOAT_WARNINGS= \
TOML_DISABLE_SHADOW_WARNINGS= \
+ TOML_DISABLE_SUGGEST_WARNINGS= \
TOML_DISABLE_ALL_WARNINGS= \
TOML_POP_WARNINGS= \
TOML_ASYMMETRICAL_EQUALITY_OPS(...)= \
diff --git a/docs/main_page.dox b/docs/main_page.dox
index f59c4f2..3efd11c 100644
--- a/docs/main_page.dox
+++ b/docs/main_page.dox
@@ -37,21 +37,20 @@
/// #include //required for parse_file()
/// #include
///
-/// int main()
+/// int main(int argc, char** argv)
/// {
/// toml::table tbl;
/// try
/// {
-/// tbl = toml::parse_file("configuration.toml");
+/// tbl = toml::parse_file(argv[1]);
+/// std::cout << tbl << std::endl;
/// }
/// catch (const toml::parse_error& err)
/// {
-/// std::cerr << "Parsing failed:\n" << err << "\n";
+/// std::cerr << "Parsing failed:\n" << err << std::endl;
/// return 1;
/// }
///
-/// do_stuff_with_your_config(tbl);
-///
/// return 0;
/// }
///
@@ -77,6 +76,8 @@
///
/// Call toml::parse() and work with the toml::table you get back, or handle any toml::parse_error that gets thrown:
///
+/// \godbolt{NsR-xf}
+///
/// \cpp
/// #include
/// #include
@@ -125,7 +126,7 @@
///
/// ... twice
/// \eout
-///
+///
/// \see
/// - toml::parse_file()
/// - toml::table
@@ -199,6 +200,9 @@
/// A TOML document is a tree of values, arrays and tables, represented as the toml::value, toml::array
/// and toml::table, respectively. All three inherit from toml::node, and can be easily accessed via
/// the toml::node_view:
+///
+/// \godbolt{ieG52U}
+///
/// \cpp
/// #include
/// #include
@@ -300,6 +304,9 @@
/// All toml++ data types have overloaded `operator<<` for ostreams, so 'serializing' a set of TOML data to actual
/// TOML is done just by printing it to an ostream. Converting it to JSON is done in the same way,
/// but via a toml::json_formatter.
+///
+/// \godbolt{MMNoW4}
+///
/// \cpp
/// #include
/// #include
diff --git a/docs/tomlplusplus.css b/docs/tomlplusplus.css
index 9cd6c59..88230d3 100644
--- a/docs/tomlplusplus.css
+++ b/docs/tomlplusplus.css
@@ -8,6 +8,11 @@ body
margin-top: 3rem;
}
+a
+{
+ text-decoration: none !important;
+}
+
header
{
position: fixed;
@@ -136,8 +141,9 @@ pre.m-code + pre.m-console span
}
/* int and float literals */
-.m-code .mi,
-.m-code .mf
+pre.m-code .mi,
+pre.m-code .mf,
+pre.m-code .mh
{
color: rgb(181,206,168);
}
@@ -248,3 +254,29 @@ main > article > .m-container.m-container-inflatable > .m-row > div.m-col-l-10.m
margin-top: -1.75rem;
max-width: calc(100% + 2rem);
}
+
+/* "Try this code on Compiler Explorer" */
+.godbolt
+{
+ font-family: 'Source Sans Pro', sans-serif;
+}
+p.godbolt
+{
+ text-align: center;
+ padding: 0.0rem;
+ text-indent: 0.0rem;
+ opacity: 0.5;
+}
+p.godbolt:hover
+{
+ opacity: 1.0;
+}
+a.godbolt
+{
+ padding: 0.5rem;
+ display: inline-block;
+}
+pre > p.godbolt
+{
+ float: right;
+}
diff --git a/include/toml++/toml.h b/include/toml++/toml.h
index 2ca4251..bea5002 100644
--- a/include/toml++/toml.h
+++ b/include/toml++/toml.h
@@ -52,13 +52,15 @@
#if TOML_UNDEF_MACROS
#undef TOML_INT_CHARCONV
#undef TOML_FLOAT_CHARCONV
- #undef TOML_GNU_ATTR
+ #undef TOML_ATTR
#undef TOML_PUSH_WARNINGS
#undef TOML_DISABLE_SWITCH_WARNINGS
#undef TOML_DISABLE_INIT_WARNINGS
#undef TOML_DISABLE_VTABLE_WARNINGS
#undef TOML_DISABLE_PADDING_WARNINGS
#undef TOML_DISABLE_FLOAT_WARNINGS
+ #undef TOML_DISABLE_SHADOW_WARNINGS
+ #undef TOML_DISABLE_SUGGEST_WARNINGS
#undef TOML_DISABLE_ALL_WARNINGS
#undef TOML_POP_WARNINGS
#undef TOML_ALWAYS_INLINE
diff --git a/include/toml++/toml_array.h b/include/toml++/toml_array.h
index cb3a4cb..48c7f8d 100644
--- a/include/toml++/toml_array.h
+++ b/include/toml++/toml_array.h
@@ -12,7 +12,7 @@ TOML_DISABLE_VTABLE_WARNINGS
namespace toml::impl
{
template
- class array_iterator final
+ class TOML_TRIVIAL_ABI array_iterator final
{
private:
friend class ::toml::array;
@@ -170,8 +170,9 @@ namespace toml::impl
template
[[nodiscard]]
+ TOML_ATTR(returns_nonnull)
TOML_ALWAYS_INLINE
- auto make_node(T&& val) noexcept
+ auto* make_node(T&& val) noexcept
{
using type = unwrapped>;
if constexpr (is_one_of)
@@ -194,8 +195,9 @@ namespace toml::impl
template
[[nodiscard]]
+ TOML_ATTR(returns_nonnull)
TOML_ALWAYS_INLINE
- auto make_node(inserter&& val) noexcept
+ auto* make_node(inserter&& val) noexcept
{
return make_node(std::move(val.value));
}
diff --git a/include/toml++/toml_array.hpp b/include/toml++/toml_array.hpp
index 6f837b6..411f28d 100644
--- a/include/toml++/toml_array.hpp
+++ b/include/toml++/toml_array.hpp
@@ -12,7 +12,10 @@
//# }}
#include "toml_array.h"
-
+
+TOML_PUSH_WARNINGS
+TOML_DISABLE_SUGGEST_WARNINGS
+
namespace toml
{
TOML_EXTERNAL_LINKAGE
@@ -45,37 +48,40 @@ namespace toml
return *this;
}
- TOML_EXTERNAL_LINKAGE node_type array::type() const noexcept { return node_type::array; }
- TOML_EXTERNAL_LINKAGE bool array::is_table() const noexcept { return false; }
- TOML_EXTERNAL_LINKAGE bool array::is_array() const noexcept { return true; }
- TOML_EXTERNAL_LINKAGE bool array::is_value() const noexcept { return false; }
- TOML_EXTERNAL_LINKAGE array* array::as_array() noexcept { return this; }
- TOML_EXTERNAL_LINKAGE const array* array::as_array() const noexcept { return this; }
+ #define TOML_MEMBER_ATTR(attr) TOML_EXTERNAL_LINKAGE TOML_ATTR(attr)
- TOML_EXTERNAL_LINKAGE node& array::operator[] (size_t index) noexcept { return *values[index]; }
- TOML_EXTERNAL_LINKAGE const node& array::operator[] (size_t index) const noexcept { return *values[index]; }
+ TOML_MEMBER_ATTR(const) node_type array::type() const noexcept { return node_type::array; }
+ TOML_MEMBER_ATTR(const) bool array::is_table() const noexcept { return false; }
+ TOML_MEMBER_ATTR(const) bool array::is_array() const noexcept { return true; }
+ TOML_MEMBER_ATTR(const) bool array::is_value() const noexcept { return false; }
+ TOML_MEMBER_ATTR(const) const array* array::as_array() const noexcept { return this; }
+ TOML_MEMBER_ATTR(const) array* array::as_array() noexcept { return this; }
- TOML_EXTERNAL_LINKAGE node& array::front() noexcept { return *values.front(); }
- TOML_EXTERNAL_LINKAGE const node& array::front() const noexcept { return *values.front(); }
- TOML_EXTERNAL_LINKAGE node& array::back() noexcept { return *values.back(); }
- TOML_EXTERNAL_LINKAGE const node& array::back() const noexcept { return *values.back(); }
+ TOML_MEMBER_ATTR(pure) const node& array::operator[] (size_t index) const noexcept { return *values[index]; }
+ TOML_MEMBER_ATTR(pure) node& array::operator[] (size_t index) noexcept { return *values[index]; }
- TOML_EXTERNAL_LINKAGE array::iterator array::begin() noexcept { return { values.begin() }; }
- TOML_EXTERNAL_LINKAGE array::const_iterator array::begin() const noexcept { return { values.begin() }; }
- TOML_EXTERNAL_LINKAGE array::const_iterator array::cbegin() const noexcept { return { values.cbegin() }; }
+ TOML_MEMBER_ATTR(pure) const node& array::front() const noexcept { return *values.front(); }
+ TOML_MEMBER_ATTR(pure) const node& array::back() const noexcept { return *values.back(); }
+ TOML_MEMBER_ATTR(pure) node& array::front() noexcept { return *values.front(); }
+ TOML_MEMBER_ATTR(pure) node& array::back() noexcept { return *values.back(); }
- TOML_EXTERNAL_LINKAGE array::iterator array::end() noexcept { return { values.end() }; }
- TOML_EXTERNAL_LINKAGE array::const_iterator array::end() const noexcept { return { values.end() }; }
- TOML_EXTERNAL_LINKAGE array::const_iterator array::cend() const noexcept { return { values.cend() }; }
+ TOML_MEMBER_ATTR(pure) array::const_iterator array::begin() const noexcept { return { values.begin() }; }
+ TOML_MEMBER_ATTR(pure) array::const_iterator array::end() const noexcept { return { values.end() }; }
+ TOML_MEMBER_ATTR(pure) array::const_iterator array::cbegin() const noexcept { return { values.cbegin() }; }
+ TOML_MEMBER_ATTR(pure) array::const_iterator array::cend() const noexcept { return { values.cend() }; }
+ TOML_MEMBER_ATTR(pure) array::iterator array::begin() noexcept { return { values.begin() }; }
+ TOML_MEMBER_ATTR(pure) array::iterator array::end() noexcept { return { values.end() }; }
- TOML_EXTERNAL_LINKAGE bool array::empty() const noexcept { return values.empty(); }
- TOML_EXTERNAL_LINKAGE size_t array::size() const noexcept { return values.size(); }
- TOML_EXTERNAL_LINKAGE void array::reserve(size_t new_capacity) { values.reserve(new_capacity); }
- TOML_EXTERNAL_LINKAGE void array::clear() noexcept { values.clear(); }
+ TOML_MEMBER_ATTR(pure) size_t array::size() const noexcept { return values.size(); }
+ TOML_MEMBER_ATTR(pure) size_t array::capacity() const noexcept { return values.capacity(); }
+ TOML_MEMBER_ATTR(pure) bool array::empty() const noexcept { return values.empty(); }
+ TOML_MEMBER_ATTR(const) size_t array::max_size() const noexcept { return values.max_size(); }
- TOML_EXTERNAL_LINKAGE size_t array::max_size() const noexcept { return values.max_size(); }
- TOML_EXTERNAL_LINKAGE size_t array::capacity() const noexcept { return values.capacity(); }
- TOML_EXTERNAL_LINKAGE void array::shrink_to_fit() { values.shrink_to_fit(); }
+ TOML_EXTERNAL_LINKAGE void array::reserve(size_t new_capacity) { values.reserve(new_capacity); }
+ TOML_EXTERNAL_LINKAGE void array::clear() noexcept { values.clear(); }
+ TOML_EXTERNAL_LINKAGE void array::shrink_to_fit() { values.shrink_to_fit(); }
+
+ #undef TOML_MEMBER_ATTR
TOML_EXTERNAL_LINKAGE
void array::truncate(size_t new_size)
@@ -103,12 +109,14 @@ namespace toml
}
TOML_EXTERNAL_LINKAGE
+ TOML_ATTR(pure)
node* array::get(size_t index) noexcept
{
return index < values.size() ? values[index].get() : nullptr;
}
TOML_EXTERNAL_LINKAGE
+ TOML_ATTR(pure)
const node* array::get(size_t index) const noexcept
{
return index < values.size() ? values[index].get() : nullptr;
@@ -225,3 +233,5 @@ namespace toml
return *this;
}
}
+
+TOML_POP_WARNINGS // TOML_DISABLE_SUGGEST_WARNINGS
diff --git a/include/toml++/toml_common.h b/include/toml++/toml_common.h
index 0b6b4f9..2590041 100644
--- a/include/toml++/toml_common.h
+++ b/include/toml++/toml_common.h
@@ -49,7 +49,7 @@ namespace toml
using ptrdiff_t = std::ptrdiff_t;
[[nodiscard]]
- TOML_GNU_ATTR(const)
+ TOML_ATTR(const)
TOML_ALWAYS_INLINE
TOML_CONSTEVAL size_t operator"" _sz(unsigned long long n) noexcept
{
@@ -299,7 +299,7 @@ namespace toml::impl
template
[[nodiscard]]
- TOML_GNU_ATTR(const)
+ TOML_ATTR(const)
TOML_ALWAYS_INLINE
constexpr std::underlying_type_t unbox_enum(T val) noexcept
{
diff --git a/include/toml++/toml_formatter.h b/include/toml++/toml_formatter.h
index b908ef4..f69648b 100644
--- a/include/toml++/toml_formatter.h
+++ b/include/toml++/toml_formatter.h
@@ -20,7 +20,7 @@ namespace toml
};
[[nodiscard]]
- TOML_GNU_ATTR(const)
+ TOML_ATTR(const)
TOML_ALWAYS_INLINE
constexpr format_flags operator & (format_flags lhs, format_flags rhs) noexcept
{
@@ -28,7 +28,7 @@ namespace toml
}
[[nodiscard]]
- TOML_GNU_ATTR(const)
+ TOML_ATTR(const)
TOML_ALWAYS_INLINE
constexpr format_flags operator | (format_flags lhs, format_flags rhs) noexcept
{
diff --git a/include/toml++/toml_node.hpp b/include/toml++/toml_node.hpp
index fc17c46..cf3699c 100644
--- a/include/toml++/toml_node.hpp
+++ b/include/toml++/toml_node.hpp
@@ -13,6 +13,9 @@
#include "toml_node.h"
+TOML_PUSH_WARNINGS
+TOML_DISABLE_SUGGEST_WARNINGS
+
namespace toml
{
TOML_EXTERNAL_LINKAGE
@@ -32,35 +35,41 @@ namespace toml
return *this;
}
- TOML_EXTERNAL_LINKAGE bool node::is_string() const noexcept { return false; }
- TOML_EXTERNAL_LINKAGE bool node::is_integer() const noexcept { return false; }
- TOML_EXTERNAL_LINKAGE bool node::is_floating_point() const noexcept { return false; }
- TOML_EXTERNAL_LINKAGE bool node::is_number() const noexcept { return false; }
- TOML_EXTERNAL_LINKAGE bool node::is_boolean() const noexcept { return false; }
- TOML_EXTERNAL_LINKAGE bool node::is_date() const noexcept { return false; }
- TOML_EXTERNAL_LINKAGE bool node::is_time() const noexcept { return false; }
- TOML_EXTERNAL_LINKAGE bool node::is_date_time() const noexcept { return false; }
- TOML_EXTERNAL_LINKAGE bool node::is_array_of_tables() const noexcept { return false; }
+ #define TOML_MEMBER_ATTR(attr) TOML_EXTERNAL_LINKAGE TOML_ATTR(attr)
- TOML_EXTERNAL_LINKAGE table* node::as_table() noexcept { return nullptr; }
- TOML_EXTERNAL_LINKAGE array* node::as_array() noexcept { return nullptr; }
- TOML_EXTERNAL_LINKAGE value* node::as_string() noexcept { return nullptr; }
- TOML_EXTERNAL_LINKAGE value* node::as_integer() noexcept { return nullptr; }
- TOML_EXTERNAL_LINKAGE value* node::as_floating_point() noexcept { return nullptr; }
- TOML_EXTERNAL_LINKAGE value* node::as_boolean() noexcept { return nullptr; }
- TOML_EXTERNAL_LINKAGE value* node::as_date() noexcept { return nullptr; }
- TOML_EXTERNAL_LINKAGE value