Skip to content

Conversation

@barcharcraz
Copy link
Contributor

@barcharcraz barcharcraz commented Apr 10, 2021

StephanTLavavej and others added 30 commits August 9, 2020 19:10
feature/format: Merge VS 2019 16.8 Preview 1 toolset update
feature/format: Merge Standard_D16as_v4 VM update
feature/format: Merge VS 2019 16.8 Preview 2 toolset update
Merge master into feature/format.
feature/format: Merge toolset update
… classes (microsoft#1232)

* add format header

* add tests to build

* add format_arg_value and custom_value.

* more format parser

* parse align

* fill/align parsing tests.

* arg_id and width

* tests for arg_id, quite basic right now

* correct a spelling error

* add <format> to other required files

* resolve some review comments

* respond to review comments

* start conversion to string_view

* some tests for width

* enable wchar_t

* constexprify tests.

* tests for non-parsing is todo

* forgot a bit of named args that needed removal.

* remove a requires clause and use brief syntax.

* newlines

* use concepts_matrix.

* some review comments were hiding from me

* fix wchar_t misparse bug

* Apply suggestions from code review

Co-authored-by: Casey Carter <cartec69@gmail.com>

* Apply suggestions from code review

Co-authored-by: Casey Carter <cartec69@gmail.com>

* move test coverage todo

* more review comments

* fix test string numbering

* comment on narrowing test case

* fix minor issues

Co-authored-by: Charles Barto <barto.charlie@gmail.com>
Co-authored-by: Casey Carter <cartec69@gmail.com>
Hand-correct trivial conflict in `tests/std/tests.lst` due to the addition of tests at the same place in both branches.
feature/format: Merge CI update to pick up microsoft#1337. There was a minor merge conflict in `test/std/test.lst` due to the addition of tests on both branches.
* add parse_precision.

* adopt style review comments.

* add more tests for exceptions.

* test constexpr precision too

* address some more review comments

Co-authored-by: Charles Barto <barto.charlie@gmail.com>
feature/format: Merge toolset update
feature/format: Merge toolset update
* add parse_precision.

* adopt style review comments.

* add parse format spec

* add tests for parse_format_specs

* actually call the test functions.

* fix tests.

* test the return value of _Parse_format_specs

* added more tests for parse_format_specs.

* address review comments.

* make "we're not done yet" a precondition for _Parse_align.

* remove test that voilates new preconditions on _Parse_align.

Co-authored-by: Charles Barto <barto.charlie@gmail.com>
feature/format: Merge toolset update
feature/format: Merge toolset update
Merge master into feature/format
feature/format: Merge toolset update
* charconv internal functions for wchar_t buffers

* fill_n for zero filling

* code review feedback
 - actually call wide Ryu functions
 - Widen __[df]2s_buffered_n
 - Don't wrap memcpy calls.
 - Use ternary operator and cast for static widen.
 - Restore _CSTD memcpy.

* Test digit pairs with a static table.

Co-authored-by: Stephan T. Lavavej <stl@nuwen.net>
* Noralize next_arg_id

* Add precondition check to basic_format_parse_context::advance_to and debug optimization

* ensure basic_format_parse_context::check_arg_id is not a constant expression

* Add tests for basic_format_parse_context

* Fix constant expression check

* windsdk is bad

* Use a non constexpr function call with a better name

Co-authored-by: S. B. Tam <cpplearner@outlook.com>

* Reverse the polarity

Co-authored-by: S. B. Tam <cpplearner@outlook.com>
Co-authored-by: Stephan T. Lavavej <stl@nuwen.net>
Pack format_arg_store tightly.


* Noralize next_arg_id

* Add precondition check to basic_format_parse_context::advance_to and debug optimization

* ensure basic_format_parse_context::check_arg_id is not a constant expression

* Add tests for basic_format_parse_context

* Fix constant expression check

* Use a non constexpr function call with a better name

Co-authored-by: S. B. Tam <cpplearner@outlook.com>

* Create a packed _Format_arg_store

* We want bits not bytes

* Dont use friendship

* Remove all int128 code

* Who doesnt hate max/min

* Copy&Paste does not like ODR

* Address review comments

Co-authored by: Casey Carter <cacarter@microsoft.com>

* Minor fixes

* Move make_format_args down

* Use auto

* Some more fixes

* Everyone can be a wchar_t if he just believe in it

* Add {unsigned} long  tests

* Int is in our hearts

* Remove duplication

* Move _CharType alias into function to unblock the build

* First round of review comments

* Use variable template rather than a function

* Add warning

* Make a proper constructor of _Format_arg_store

* Use a single contiguous array to store the `_Format_arg_store` data

* Specialize empty `_Format_arg_store`

* More review comments

* Fix uninitialized memory

* Properly initialize the first Index

Co-authored-by: S. B. Tam <cpplearner@outlook.com>
* add parse_precision.

* adopt style review comments.

* actually call the test functions.

* add parse_precision.

* adopt style review comments.

* add parse format spec

* add tests for parse_format_specs

* initial commit for string_parsing

* remove duplicate test frunctions

* on_text and some on_format_specs

* add basic_format_specs and the formatter dispatcher.

* forgot a semicolon.

* now we need to do _Write... :|

* more work on format checkers

* add _Format_arg_type_to_enum

* add char* writer

* make it compile

* flesh out format_args_store.

* don't need overloaded

* get rid of a bunch of declvals.

* compile vformat (does not link)

* make width and precision unsigned int internally (instead of int)

* add some comments for shat the various helpery classes actually do.

* formatting (heh) fixes.

* uncomment and fix requirement for _Parse_replacement_field_callbacks

* don't write out the entire format string when encountering a replacement field.

* resolve some code review comments

* fix merge artifacts, convert from _Type to _Basic_format_arg_type

* address code review comments

* alphabatize test.lst

* static_cast<unsigned int>(0) instead of unsigned{}

* remove dead _STL_INTERNAL_CHECK and find in the correct range

Co-authored-by: Charles Barto <barto.charlie@gmail.com>
* add tests for various escaped curlies and simple text.
* better comment in _Parse_format_string

Co-authored-by: Casey Carter <cartec69@gmail.com>
…icrosoft#1675)

* intial replacement field tests (and numeric arg indexing)
@StephanTLavavej
Copy link
Member

  • Include more headers.
  • In P0645R10_text_formatting_formatting, rename integral to Integral to avoid shadowing the Standard concept.
  • Representation change: Change _Align and _Sign's underlying type to uint8_t. _Align is stored as a data member, so this matters.
  • static_assert that _Basic_format_arg_type::_Custom_type is strictly less than 16, because it must fit in a 4-bit bitfield.
  • Style: Add newlines.
  • Bugfix: Add missing typedefs format_parse_context and wformat_parse_context.
  • Representation change (sort of): basic_format_arg::handle should store a __cdecl function pointer. This will make it immune to the default calling convention.
  • Bugfix (maybe?): basic_format_arg::handle::format() is const in the Standard.
  • Bugfix: visit_format_arg() must return decltype(auto) as depicted by the Standard.
  • Style: constexpr explicit is conventional.
  • Add _NODISCARD to _Find_encoded().
  • Style: Use braces to construct temporaries.
  • Style: In _Format_arg_store_packed_index, avoid shadowing between the constructor parameter and data member, and remove an unnecessary static_cast (they're both size_t).
  • Representation change: Add alignas(_Index_type) to _Format_arg_store::_Storage.
    • Also fix the comment; _Index_length is the number of bytes needed to store _Num_args elements of type _Format_arg_store_packed_index.
  • Improve comments.
    • Fix typo, _OpenCurl should be _OpeningCurl.
    • Add a WP citation.
    • Overhaul the _Format_min_buffer_length comment, fixing its math.
    • "hex number" is slightly unclear; other comments in the STL (especially <charconv>) say "hexit" (for "hexadecimal digit").
    • I couldn't understand what "(with overloaded)" intended to say, so I dropped it.
    • Capitalize "ASCII".
  • Style: Adjust spacing and indentation of requires clauses. A space goes after requires when it doesn't look like a function signature.
  • Style: When declaring functions, don't mark value parameters as const.
  • Use isfinite for simplicity.
  • Style: Use _Nx for N instead of _Nty (it's not a type, or a number of types).
  • Big rename: _Align to _Fmt_align.
  • Big rename: _Sign to _Fmt_sign.

@CaseyCarter CaseyCarter self-assigned this Apr 14, 2021
@StephanTLavavej
Copy link
Member

I've pushed a merge with main to resolve a conflict with #1832 in <xutility>: that PR added _Rewrap_iterator above _Convertible_from which this PR is moving. I resolved it by leaving _Rewrap_iterator in place (now immediately above in_in_result) so only _Convertible_from is moving. This is fine because nothing in <xutility> itself needs _Rewrap_iterator.

@StephanTLavavej StephanTLavavej merged commit c12089e into microsoft:main Apr 15, 2021
@StephanTLavavej
Copy link
Member

Thanks to everyone who worked on implementing this major feature! 🎉 😻 🚀

@Sixshaman
Copy link

Thank you everyone! I've been waiting for that

@CaseyCarter
Copy link
Contributor

Belated approval: everything looks acceptable to me (which is no great surprise, since I've reviewed most of this already, and worked on some of it).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cxx20 C++20 feature format C++20/23 format

Projects

None yet

Development

Successfully merging this pull request may close these issues.

<format>: Avoid dependency on <variant> P0645R10 <format> Text Formatting

10 participants