| 1 |
// { dg-do compile { target c++23 } } |
| 2 |
|
| 3 |
#include <format> |
| 4 |
#include <vector> |
| 5 |
|
| 6 |
// only format_kind::sequence provides set_brackets and set_separator methods |
| 7 |
|
| 8 |
template<std::range_format fk, typename T> |
| 9 |
struct MyCont : std::vector<T> |
| 10 |
{ |
| 11 |
using std::vector<T>::vector; |
| 12 |
}; |
| 13 |
|
| 14 |
template<std::range_format fk, typename T> |
| 15 |
constexpr std::range_format std::format_kind<MyCont<fk, T>> = fk; |
| 16 |
|
| 17 |
void test_sequence() |
| 18 |
{ |
| 19 |
std::formatter<MyCont<std::range_format::sequence, int>, char> fmtter; |
| 20 |
fmtter.set_brackets("{", "}"); |
| 21 |
fmtter.set_separator(","); |
| 22 |
} |
| 23 |
|
| 24 |
void test_map() |
| 25 |
{ |
| 26 |
std::formatter<MyCont<std::range_format::map, std::pair<int, int>>, char> fmtter; |
| 27 |
fmtter.set_brackets("{", "}"); // { dg-error "here" } |
| 28 |
fmtter.set_separator(","); // { dg-error "here" } |
| 29 |
} |
| 30 |
|
| 31 |
void test_set() |
| 32 |
{ |
| 33 |
std::formatter<MyCont<std::range_format::set, int>, char> fmtter; |
| 34 |
fmtter.set_brackets("{", "}"); // { dg-error "here" } |
| 35 |
fmtter.set_separator(","); // { dg-error "here" } |
| 36 |
} |
| 37 |
|
| 38 |
void test_string() |
| 39 |
{ |
| 40 |
std::formatter<MyCont<std::range_format::string, char>, char> fmtter; |
| 41 |
fmtter.set_brackets("{", "}"); // { dg-error "here" } |
| 42 |
fmtter.set_separator(","); // { dg-error "here" } |
| 43 |
} |
| 44 |
|
| 45 |
void test_debug_string() |
| 46 |
{ |
| 47 |
std::formatter<MyCont<std::range_format::debug_string, char>, char> fmtter; |
| 48 |
fmtter.set_brackets("{", "}"); // { dg-error "here" } |
| 49 |
fmtter.set_separator(","); // { dg-error "here" } |
| 50 |
} |
| 51 |
|
| 52 |
// { dg-error "no matching function for call to 'std::formatter<" "" { target *-*-* } 0 } |