This is not strictly required, but avoids potential circular header
dependencies when there will be an formatter specialization for
optional.
Details
- Reviewers
- None
- Group Reviewers
Restricted Project
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
libcxx/include/__format/format_context.h | ||
---|---|---|
17 | IMO it would be nice to be able to keep using optional here. I am not concerned about potential circular dependency problems because we could always granularize <optional> into <__optional/optional.h> and <__optional/formatter.h>. Then here you'd include <__optional/optional.h> only. | |
71–75 | It's surprising to provide a move constructor here if the underlying locale is not movable. Also, should we be disengaging __other? | |
77–85 | If you retain this, you could inline __assign into operator=(__locale const&) and call operator=(__locale const&) from operator=(__locale&&). And actually you don't need to provide operator=(__locale&&) at all, since the copy-assignment will be used if you do x = std::move(y) and x only has a copy-assignment. |
I'm with ldionne that we should keep using optional here. The correctness seems like a very important quality that we'll be loosing some certainty in.
libcxx/include/__format/format_context.h | ||
---|---|---|
56 | I think __locale is already a class inside namespace std. I would prefer that we use a slightly different name so it's more clear when the type is spelled elsewhere. |
My main concern was when we need a formatter<optional, charT>. In D150509 I tested an alternative approach as suggested by Louis, which works without creating header cycles. So when somebody writes a paper for such a formatter we don't risk possible ABI breaks.
(MSVC STL and libstdc++ don't use an optional to implement the locale.)
Since the alternative works, this patch will be abandoned.
IMO it would be nice to be able to keep using optional here. I am not concerned about potential circular dependency problems because we could always granularize <optional> into <__optional/optional.h> and <__optional/formatter.h>. Then here you'd include <__optional/optional.h> only.