Skip to content

Commit

Permalink
fix for_each() for older MSVC
Browse files Browse the repository at this point in the history
  • Loading branch information
marzer committed Apr 24, 2022
1 parent bf13bbd commit 85c5128
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
5 changes: 4 additions & 1 deletion include/toml++/impl/array.h
Original file line number Diff line number Diff line change
Expand Up @@ -887,7 +887,10 @@ TOML_NAMESPACE_START
const auto keep_going =
static_cast<node_ref>(static_cast<Array&&>(arr)[i])
.visit(
[&](auto&& elem) noexcept(for_each_is_nothrow_one<Func&&, Array&&, decltype(elem)>)
[&](auto&& elem)
#if !TOML_MSVC || TOML_MSVC >= 1932 // older MSVC thinks this is invalid syntax O_o
noexcept(for_each_is_nothrow_one<Func&&, Array&&, decltype(elem)>)
#endif
{
using elem_ref = for_each_elem_ref<decltype(elem), Array&&>;
static_assert(std::is_reference_v<elem_ref>);
Expand Down
5 changes: 4 additions & 1 deletion include/toml++/impl/table.h
Original file line number Diff line number Diff line change
Expand Up @@ -899,7 +899,10 @@ TOML_NAMESPACE_START
const auto keep_going =
static_cast<node_ref>(*kvp.second)
.visit(
[&](auto&& v) noexcept(for_each_is_nothrow_one<Func&&, Table&&, decltype(v)>)
[&](auto&& v)
#if !TOML_MSVC || TOML_MSVC >= 1932 // older MSVC thinks this is invalid syntax O_o
noexcept(for_each_is_nothrow_one<Func&&, Table&&, decltype(v)>)
#endif
{
using value_ref = for_each_value_ref<decltype(v), Table&&>;
static_assert(std::is_reference_v<value_ref>);
Expand Down
10 changes: 8 additions & 2 deletions toml.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5625,7 +5625,10 @@ TOML_NAMESPACE_START
const auto keep_going =
static_cast<node_ref>(static_cast<Array&&>(arr)[i])
.visit(
[&](auto&& elem) noexcept(for_each_is_nothrow_one<Func&&, Array&&, decltype(elem)>)
[&](auto&& elem)
#if !TOML_MSVC || TOML_MSVC >= 1932 // older MSVC thinks this is invalid syntax O_o
noexcept(for_each_is_nothrow_one<Func&&, Array&&, decltype(elem)>)
#endif
{
using elem_ref = for_each_elem_ref<decltype(elem), Array&&>;
static_assert(std::is_reference_v<elem_ref>);
Expand Down Expand Up @@ -6931,7 +6934,10 @@ TOML_NAMESPACE_START
const auto keep_going =
static_cast<node_ref>(*kvp.second)
.visit(
[&](auto&& v) noexcept(for_each_is_nothrow_one<Func&&, Table&&, decltype(v)>)
[&](auto&& v)
#if !TOML_MSVC || TOML_MSVC >= 1932 // older MSVC thinks this is invalid syntax O_o
noexcept(for_each_is_nothrow_one<Func&&, Table&&, decltype(v)>)
#endif
{
using value_ref = for_each_value_ref<decltype(v), Table&&>;
static_assert(std::is_reference_v<value_ref>);
Expand Down

0 comments on commit 85c5128

Please sign in to comment.