| 1 |
// PR c++/122070 |
| 2 |
// { dg-do compile { target c++23 } } |
| 3 |
|
| 4 |
namespace std { |
| 5 |
using size_t = decltype(sizeof(0)); |
| 6 |
template<typename CharT> |
| 7 |
struct basic_string_view { |
| 8 |
const CharT* ptr; |
| 9 |
size_t len; |
| 10 |
constexpr basic_string_view(const CharT* p) : ptr(p), len(0) { while (p && p[len]) ++len; } |
| 11 |
}; |
| 12 |
using string_view = basic_string_view<char>; |
| 13 |
} |
| 14 |
|
| 15 |
template<std::size_t N> |
| 16 |
struct sized_string_view: std::string_view { |
| 17 |
using std::string_view::string_view; |
| 18 |
}; |
| 19 |
template<std::size_t N> |
| 20 |
sized_string_view(const char (&str)[N]) -> sized_string_view<N - 1>; |
| 21 |
|
| 22 |
constexpr auto string_builder(auto first, auto second, auto... trailing) { |
| 23 |
constexpr auto is_last = sizeof...(trailing) == 0; |
| 24 |
auto buffer = 1; |
| 25 |
if constexpr (is_last) { |
| 26 |
return buffer; |
| 27 |
} else |
| 28 |
return string_builder(buffer, trailing...); |
| 29 |
} |
| 30 |
|
| 31 |
constexpr auto copyright = string_builder(sized_string_view("a"), sized_string_view("b"), sized_string_view("c")); |