Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

User-defined literals improvements #1254

Merged
merged 4 commits into from Aug 1, 2019
Merged

User-defined literals improvements #1254

merged 4 commits into from Aug 1, 2019

Conversation

sylveon
Copy link
Contributor

@sylveon sylveon commented Jul 27, 2019

I agree that my contributions are licensed under the {fmt} license, and agree to future changes to the licensing.

This is a few couple improvements to literals formatting API.

  • It uses forwarding references in the UDL template version instead of const references.
  • Simplifies the overly verbose return type of udl_formatter.
  • Makes use of basic_string_view to store the format string and argument name instead of raw character pointers.
  • Makes all the literal operators constexpr.
  • Adds the possibility of defining FMT_USING_LITERALS to allow all code at a project level to use the _format and _a operator.

@vitaut
Copy link
Contributor

vitaut commented Aug 1, 2019

Thanks a lot for the PR. All looks good but I'd rather not have a using directive in a header even as an opt-in. If users want something like that they can create a small wrapper header.


template <typename... Args>
auto operator()(Args&&... args) const
-> decltype(format(str, std::forward<Args>(args)...)) {
std::basic_string<Char> operator()(Args&&... args) const {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@sylveon
Copy link
Contributor Author

sylveon commented Aug 1, 2019

Fair enough, I've rebased the branch to drop those two commits.

@vitaut vitaut merged commit 1dfa259 into fmtlib:master Aug 1, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants