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

[time.syn] Unclear namespace prefix for literal operators #3328

Closed
jensmaurer opened this issue Oct 25, 2019 · 4 comments
Closed

[time.syn] Unclear namespace prefix for literal operators #3328

jensmaurer opened this issue Oct 25, 2019 · 4 comments

Comments

@jensmaurer
Copy link
Member

Why do the literal operators (such as operator ""s) shown in the header synopsis have a qualified-id as the return type?

Ordinary unqualified lookup would/should find std::chrono::month from a subnamespace of std::chrono, too, I thought.

This relates to consistency issues in the itemdecls of operator""y and operator""d, raised by
JP338 cplusplus/nbballot#334 and JP 343 cplusplus/nbballot#339.

@jensmaurer jensmaurer added the decision-required A decision of the editorial group (or the Project Editor) is required. label Oct 25, 2019
@CaseyCarter
Copy link
Contributor

CaseyCarter commented Oct 25, 2019

The <chrono> synopsis is in [time.syn] - there is no subclause [chrono.syn]. I have no explanation for why many of the names are qualified - e.g. struct common_type<chrono::duration in namespace std::chrono need not be qualified - other than that std::chrono was one of our first nested namespaces and LWG policy for how to specify components in sub-namespaces of std was less developed than today.

@jensmaurer jensmaurer changed the title [chrono.syn] Unclear namespace prefix for literal operators [time.syn] Unclear namespace prefix for literal operators Oct 25, 2019
@jensmaurer
Copy link
Member Author

std::filesystem is way older than std::chrono, yet we still don't describe the "leave off namespaces" presentation form properly.

@CaseyCarter
Copy link
Contributor

CaseyCarter commented Oct 25, 2019

std::filesystem is way older than std::chrono, yet we still don't describe the "leave off namespaces" presentation form properly.

std::chrono was added in C++11, std::filesystem in C++17. The example I pointed out above is completely invalid, however, since it's a specialization of common_type in namespace std and therefore must qualify chrono::duration.

Let's start over: The user-defined literals in <chrono> are defined in namespace std::literals::chrono_literals, which is not a subnamespace of std::chrono, so the return types must be chrono::-qualified; they would not be found by unqualified lookup.

@jensmaurer
Copy link
Member Author

I apparently overlooked a closing brace from a previous "namespace chrono {".

So, I agree we need the "chrono::" qualification on the return type for the literal operators. Thanks for looking into this.

@jensmaurer jensmaurer removed the decision-required A decision of the editorial group (or the Project Editor) is required. label Oct 25, 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

No branches or pull requests

2 participants