Add formatters for container adapters - #3279
Merged
Merged
Conversation
ShawnZhong
force-pushed
the
container-adapter
branch
from
January 18, 2023 02:44
d2aad2d to
82175fe
Compare
ShawnZhong
force-pushed
the
container-adapter
branch
from
January 18, 2023 02:46
82175fe to
6154473
Compare
vitaut
reviewed
Jan 22, 2023
| struct formatter<T, Char, | ||
| enable_if_t<detail::is_container_adaptor_like<T>::value>> { | ||
| private: | ||
| struct formatter<typename T::container_type, Char> container_formatter; |
Contributor
There was a problem hiding this comment.
struct not needed here and I suggest using inheritance instead of composition to avoid redefining parse.
Also please apply clang-format, indent is a bit off.
Contributor
|
Thank you! |
vitaut
reviewed
Feb 9, 2023
Comment on lines
+450
to
+452
| // Note: The output is formatted as a string because the underlying | ||
| // container is a string. This behavior is conforming to the standard | ||
| // [container.adaptors.format]. |
Contributor
There was a problem hiding this comment.
This is inconsistent with formatting containers and looks like an oversight. I think we should open an LWG issue.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Close #3215.
https://eel.is/c++draft/container.adaptors.format specifies formatting for container adapters (
std::stack,std::queue, andstd::priority_queuein particular).Not sure if the implementation should go into
ranges.horstd.h. I'm putting it inranges.hfor now because I don't want to makestd.hdepend onranges.h.Container adapters have a protected member
Container c, which can be exposed by defining a derived class.