Title
Misleading note about calls to customization points
Status
open
Section
[namespace.std]
Submitter
Michael Park

Created on 2020-05-08.00:00:00 last changed 1 month ago

Messages

Date: 2020-10-02.18:55:49

Proposed resolution:

This wording is relative to N4861.

  1. Modify [namespace.std] as indicated:

    -7- Other than in namespace std or in a namespace within namespace std, a program may provide an overload for any library function template designated as a customization point, provided that (a) the overload's declaration depends on at least one user-defined type and (b) the overload meets the standard library requirements for the customization point. (footnote 173) [Note: This permits a (qualified or unqualified) call to the customization point to invoke the most appropriate overload for the given arguments. — end note]

Date: 2020-10-15.00:00:00

[ 2020-10-02; status to Open ]

Date: 2020-09-15.00:00:00

[ 2020-09-11; discussed during telecon ]

The note is simply bogus, not backed up by anything normative. The normative part of the paragraph is an unacceptable landgrab on those identifiers. We have no right telling users they can't use the names data and size unless they do exactly what we say std::data and std::size do. The library only ever uses swap unqualified, so the effect of declaring the others as designated customization points is unclear.

The rule only needs to apply to such overloads when actually found by overload resolution in a context that expects the semantics of the customization point.

Frank: do we need to designate operator<< as a customization point? Users overload that in their own namespaces all the time.

Walter: This clearly needs a paper.

Date: 2020-07-15.00:00:00

[ 2020-07-17; Priority set to 1 in telecon ]

Related to 3442.

Date: 2020-05-08.00:00:00

P0551 (Thou Shalt Not Specialize std Function Templates!) added a clause in [namespace.std]/7:

Other than in namespace std or in a namespace within namespace std, a program may provide an overload for any library function template designated as a customization point, provided that (a) the overload's declaration depends on at least one user-defined type and (b) the overload meets the standard library requirements for the customization point. (footnote 174) [Note: This permits a (qualified or unqualified) call to the customization point to invoke the most appropriate overload for the given arguments. — end note]

Given that std::swap is a designated customization point, the note seems to suggest the following:

namespace N {
  struct X {};
  void swap(X&, X&) {}
}

N::X a, b;
std::swap(a, b); // qualified call to customization point finds N::swap?

This is not what happens, as the call to std::swap does not find N::swap.

History
Date User Action Args
2020-10-02 18:55:49adminsetmessages: + msg11500
2020-10-02 18:55:49adminsetstatus: new -> open
2020-09-12 11:45:45adminsetmessages: + msg11477
2020-07-17 22:37:26adminsetmessages: + msg11377
2020-05-09 19:58:13adminsetmessages: + msg11281
2020-05-08 00:00:00admincreate