Skip to content

Commit 732e6c1

Browse files
authored
Revise json_auto_tuple_mono to match the entire tuple (#1780)
Signed-off-by: Juan Cruz Viotti <jv@jviotti.com>
1 parent 90593dd commit 732e6c1

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/core/json/include/sourcemeta/core/json_auto.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,9 @@ concept json_auto_map_like =
7777

7878
/// @ingroup json
7979
template <typename T>
80-
concept json_auto_tuple_mono =
81-
std::tuple_size_v<std::remove_cvref_t<std::tuple<T>>> == 1;
80+
concept json_auto_tuple_mono = requires {
81+
typename std::tuple_size<std::remove_cvref_t<T>>::type;
82+
} && (std::tuple_size_v<std::remove_cvref_t<T>> == 1);
8283

8384
// We have to do this mess because MSVC seems confuses `std::pair`
8485
// of 2 elements with this overload
@@ -233,10 +234,9 @@ auto to_json(const std::pair<L, R> &value) -> JSON {
233234

234235
// Handle 1-element tuples
235236
/// @ingroup json
236-
template <json_auto_tuple_mono T>
237-
auto to_json(const std::tuple<T> &value) -> JSON {
237+
template <json_auto_tuple_mono T> auto to_json(const T &value) -> JSON {
238238
auto tuple = JSON::make_array();
239-
std::apply([&](const T &element) { tuple.push_back(to_json(element)); },
239+
std::apply([&](const auto &element) { tuple.push_back(to_json(element)); },
240240
value);
241241
return tuple;
242242
}

0 commit comments

Comments
 (0)