Skip to content

Commit 538776d

Browse files
committed
Fix casting std::any to std::string
Current implementation had ambiguity. After this change the casts works.
1 parent 74eb1d5 commit 538776d

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
@@ -1293,11 +1293,9 @@ constexpr auto has_recursive_to_string_overload(C<Ts...> const&)
12931293

12941294

12951295
template <std::same_as<std::string> C, has_to_string_overload X>
1296-
requires not_same_as<X, std::string> && (same_type_as<X, bool> || no_brace_initializable_to<X, C>)
1296+
requires not_one_of<X, std::string, std::any> && (same_type_as<X, bool> || no_brace_initializable_to<X, C>)
12971297
auto as( X&& x ) {
1298-
if constexpr (same_type_as<X, std::any>) {
1299-
return nonesuch_<cpp2::casting_errors::no_to_string_cast>{};
1300-
} else if constexpr (specialization_of_template<X, std::variant>
1298+
if constexpr (specialization_of_template<X, std::variant>
13011299
&& requires {
13021300
{ has_recursive_to_string_overload(x) } -> std::same_as<std::false_type>;
13031301
}

0 commit comments

Comments
 (0)