<format>: Simplify type-erased argument storage#1907
Conversation
Rename the overload set that emulates the exposition-only constructors of `basic_format_arg` from `_Get_format_arg_storage_type` to `_Phony_basic_format_arg_constructor` for clarity. Encapsulate that overload set - and the traits `_Storage_type` and `_Storage_size` that observe it - in a new class template `_Format_arg_traits`. Remove the bogus `monostate` case and split the floating-point types out from the function template overload to more closely reflect the `basic_format_arg` constructors. Shorten `_Format_arg_store_packed_index` to `_Format_arg_index` and make its converting constructor unconditionally `noexcept`. In `_Format_arg_store`, store indices in an array using the untyped storage only for erased arguments. In `_Store`, reuse `_Format_arg_traits::_Storage_type` instead of trying to duplicate the overload resolution process.
|
I thought you could store monostates and observe them through |
You can EDIT: I note that we are missing test coverage of |
<format>: Simplify type-erased argument storage
StephanTLavavej
left a comment
There was a problem hiding this comment.
Looks good - I will validate and push changes for ultra-trivial nitpicks.
|
Thanks for simplifying |
Rename the overload set that emulates the exposition-only constructors of
basic_format_argfrom_Get_format_arg_storage_typeto_Phony_basic_format_arg_constructorfor clarity. Encapsulate that overload set - and the traits_Storage_typeand_Storage_sizethat observe it - in a new class template_Format_arg_traits. Remove the bogusmonostatecase and split the floating-point types out from the function template overload to more closely reflect thebasic_format_argconstructors.Shorten
_Format_arg_store_packed_indexto_Format_arg_indexand make its converting constructor unconditionallynoexcept.In
_Format_arg_store, store indices in an array using the untyped storage only for erased arguments. In_Store, reuse_Format_arg_traits::_Storage_typeinstead of trying to duplicate the overload resolution process.Add test coverage for
visit_format_arg(/**/, basic_format_arg</**/>())to ensure that themonostateis properly visitable.