| 1 |
// { dg-do compile { target c++11 } } |
| 2 |
#include <string> |
| 3 |
|
| 4 |
std::string s = nullptr; // { dg-error "deleted" "P2166R1" { target c++23 } } |
| 5 |
|
| 6 |
struct S |
| 7 |
{ |
| 8 |
operator const char*() const { return ""; } |
| 9 |
operator std::nullptr_t() const { return {}; } |
| 10 |
}; |
| 11 |
|
| 12 |
std::string s2{ S{} }; // { dg-error "deleted" "PR 104099" { target c++23 } } |
| 13 |
|
| 14 |
#if __cpp_concepts |
| 15 |
struct J |
| 16 |
{ |
| 17 |
// In C++20 this selects basic_string(const char*), |
| 18 |
// in C++23 it's ambiguous due to basic_string(nullptr_t). |
| 19 |
template<typename T> |
| 20 |
requires (!std::is_same_v<std::allocator<char>, T>) |
| 21 |
&& (!std::is_same_v<std::string, T>) |
| 22 |
&& (!std::is_same_v<char, T>) |
| 23 |
&& (!std::is_same_v<std::string_view, T>) |
| 24 |
operator T() const { return {}; } |
| 25 |
}; |
| 26 |
|
| 27 |
std::string s3{ J{} }; // { dg-error "ambiguous" "PR 104099" { target c++23 } } |
| 28 |
#endif |