Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
4dde166
Add `range_formatter`
JMazurkiewicz Apr 28, 2024
2e4fbbd
Rearrange entries in `expected_results.txt`
JMazurkiewicz Apr 30, 2024
f3e0e5e
Use `_Is_two_tuple` and remove `_Pair_like_with_formatter`
JMazurkiewicz Apr 30, 2024
2102ddd
Use `size_t` instead of `_String_view::size_type`
JMazurkiewicz Apr 30, 2024
2363bde
Remove `_String_view` alias
JMazurkiewicz Apr 30, 2024
5d2d147
Rename `_String_formatter` to `_String_view_formatter`
JMazurkiewicz Apr 30, 2024
bfabe6e
Add `if constexpr` to verify if `max(SignedLike) > max(size_t)`
JMazurkiewicz Apr 30, 2024
af78d8e
Fix condition `_Size >= _Size_t_max` => `_Size > _Size_t_max`
JMazurkiewicz Apr 30, 2024
adc5f8d
Fix parsing of `range-fill-and-align`
JMazurkiewicz May 2, 2024
783cd70
Merge remote-tracking branch 'upstream/main' into format/ranges
JMazurkiewicz May 2, 2024
753a515
Fix formatting
JMazurkiewicz May 2, 2024
2c5a252
`check_setters` -> `check_other_functions`
JMazurkiewicz May 14, 2024
ac8b925
Fix `range_formatter` for arbitrary format context
JMazurkiewicz May 14, 2024
24cdb13
Remove unnecessary `if` from `_Parse_range_specs`
JMazurkiewicz May 15, 2024
58c123f
Cleanup `check_range_formatter_with_arbitrary_context`
JMazurkiewicz May 15, 2024
e993011
Remove unnecessary call to `set_separator` from `range_formatter::parse`
JMazurkiewicz May 15, 2024
a0cc0c3
Fix order of actions in `range_formatter::parse`
JMazurkiewicz May 15, 2024
5e00dba
Merge remote-tracking branch 'upstream/main' into format/ranges
JMazurkiewicz May 25, 2024
f163372
Use `_Measure_display_width`
JMazurkiewicz May 26, 2024
c931c77
Address #4636
JMazurkiewicz May 26, 2024
8f60263
Add `_EXPORT_STD`
JMazurkiewicz May 27, 2024
05408d2
Always `break`, even for the last `case`.
StephanTLavavej May 29, 2024
875f9ce
Use `back_insert_iterator` CTAD.
StephanTLavavej May 29, 2024
60c261e
Flip test, avoid dead code with `if constexpr { } else { }`.
StephanTLavavej May 29, 2024
2132330
Mark `underlying()` as `_NODISCARD`.
StephanTLavavej May 29, 2024
b6c4d5e
Add `const`.
StephanTLavavej May 29, 2024
ee614c0
Simplify with `in_range`.
StephanTLavavej May 29, 2024
6f245a8
Improve messages, flip and split tests.
StephanTLavavej May 29, 2024
8a79bcc
Simplify `_Parse_range_specs` to always take `_Range_specs_setter<_Ch…
StephanTLavavej May 29, 2024
5027c57
`Debugable` => `Debuggable`
StephanTLavavej May 29, 2024
cd9efc2
Work around MSVC compiler bug.
StephanTLavavej May 29, 2024
d7c5a0b
Include more headers.
StephanTLavavej May 29, 2024
e0a73f2
Construct `format_error` with braces.
StephanTLavavej May 29, 2024
bba1416
Drop duplicated line.
StephanTLavavej May 29, 2024
690ae85
Order vs. chaos.
StephanTLavavej May 29, 2024
bd4704a
Fix missing `set_separator` for 'm', and test it.
StephanTLavavej May 29, 2024
b71b448
Reduce compiler memory consumption for the instantiation test.
StephanTLavavej May 30, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix missing set_separator for 'm', and test it.
Verified that the new test coverage fails without the fix.
  • Loading branch information
StephanTLavavej committed May 29, 2024
commit bd4704ab29797697f5247c84cc5ad0f49986e8bf
1 change: 1 addition & 0 deletions stl/inc/format
Original file line number Diff line number Diff line change
Expand Up @@ -4484,6 +4484,7 @@ public:
case 'm':
if constexpr (_Is_two_tuple<_Ty>) {
set_brackets(_STATICALLY_WIDEN(_CharT, "{"), _STATICALLY_WIDEN(_CharT, "}"));
set_separator(_STATICALLY_WIDEN(_CharT, ", "));
_Underlying.set_brackets({}, {});
_Underlying.set_separator(_STATICALLY_WIDEN(_CharT, ": "));
Comment thread
StephanTLavavej marked this conversation as resolved.
Resolved
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,49 @@ consteval bool check_constraints() {
return true;
}

template <class T>
struct WrappedVector : vector<T> {
using vector<T>::vector;
};

template <class T, class CharT>
struct std::formatter<WrappedVector<T>, CharT> {
public:
template <class ParseContext>
constexpr auto parse(ParseContext& ctx) {
underlying.set_brackets(STR("<"sv), STR(">"sv));
underlying.set_separator(STR("|"sv));
return underlying.parse(ctx);
}

template <class FormatContext>
auto format(const WrappedVector<T>& rng, FormatContext& ctx) const {
return underlying.format(rng, ctx);
}

private:
range_formatter<T, CharT> underlying;
};

template <class CharT>
void check_runtime_behavior_of_setters() {
{
const WrappedVector<int> v1{11, 22, 33, 44};
assert(format(STR("{}"), v1) == STR("<11|22|33|44>"));
assert(format(STR("{:}"), v1) == STR("<11|22|33|44>"));
assert(format(STR("{:n}"), v1) == STR("11|22|33|44"));
}

{
const WrappedVector<pair<int, char>> v2{{10, 'x'}, {20, 'y'}, {30, 'z'}};
assert(format(STR("{}"), v2) == STR("<(10, 'x')|(20, 'y')|(30, 'z')>"));
assert(format(STR("{:}"), v2) == STR("<(10, 'x')|(20, 'y')|(30, 'z')>"));
assert(format(STR("{:n}"), v2) == STR("(10, 'x')|(20, 'y')|(30, 'z')"));
assert(format(STR("{:m}"), v2) == STR("{10: 'x', 20: 'y', 30: 'z'}"));
assert(format(STR("{:nm}"), v2) == STR("10: 'x', 20: 'y', 30: 'z'"));
}
}

int main() {
test_in<range_formatter_check_instantiator, const int>();

Expand All @@ -449,4 +492,7 @@ int main() {

static_assert(check_constraints<char>());
static_assert(check_constraints<wchar_t>());

check_runtime_behavior_of_setters<char>();
check_runtime_behavior_of_setters<wchar_t>();
}