Skip to content

Commit b2aac74

Browse files
committed
Fix casting std::any to std::string
Current implementation had ambiguity. After this change the casts works.
1 parent 115bd73 commit b2aac74

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

include/cpp2util.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1299,11 +1299,9 @@ constexpr auto has_recursive_to_string_overload(C<Ts...> const&)
12991299

13001300

13011301
template <std::same_as<std::string> C, has_to_string_overload X>
1302-
requires not_same_as<X, std::string> && (same_type_as<X, bool> || no_brace_initializable_to<X, C>)
1302+
requires not_one_of<X, std::string, std::any> && (same_type_as<X, bool> || no_brace_initializable_to<X, C>)
13031303
auto as( X&& x ) {
1304-
if constexpr (same_type_as<X, std::any>) {
1305-
return nonesuch_<cpp2::casting_errors::no_to_string_cast>{};
1306-
} else if constexpr (specialization_of_template<X, std::variant>
1304+
if constexpr (specialization_of_template<X, std::variant>
13071305
&& requires {
13081306
{ has_recursive_to_string_overload(x) } -> std::same_as<std::false_type>;
13091307
}

0 commit comments

Comments
 (0)