Title
§[global.functions] provides incorrect example of ADL use
Status
c++17
Section
[global.functions]
Submitter
Jonathan Wakely

Created on 2016-11-09.00:00:00 last changed 81 months ago

Messages

Date: 2016-12-16.20:56:38

Proposed resolution:

This wording is relative to N4606.

  1. Change [global.functions] p4:

    Unless otherwise specified, calls made by functions in the standard library to non-operator, non-member functions in the standard library shalldo not use functions from another namespace which are found through argument-dependent name lookup (3.4.2). [Note: The phrase "unless otherwise specified" applies to cases such as the swappable with requirements ([swappable.requirements]). The exception for overloaded operators allowsis intended to allow argument-dependent lookup in cases like that of ostream_iterator::operator= (24.6.2.2):

    Effects:

    *out_stream << value;
    if (delim != 0)
      *out_stream << delim ;
    return *this;
    

    end note]

Date: 2017-02-02.00:41:18

[ Issues Telecon 16-Dec-2016 ]

Move to Tentatively Ready

Date: 2016-11-15.00:00:00

[ 2016-11-10, Tim Song and Jonathan agree on new wording ]

The new wording still doesn't quite get it right:

"calls to non-operator, non-member functions in the standard library do not use functions from another namespace which are found through argument-dependent name lookup" can be interpreted as saying that if a user writes "std::equal(a, b, c, d)", that call will not use ADL'd "operator==" because "std::equal(a, b, c, d)" is a "call" to a "non-operator, non-member function in the standard library".

The key point here is that "in the standard library" should be modifying "calls", not "function".

Previous resolution [SUPERSEDED]:

This wording is relative to N4606.

  1. Change [global.functions] p4:

    Unless otherwise specified, non-operator, non-member functions in the standard library shall not use functions from another namespace which are found through argument-dependent name lookup (3.4.2). [Note: The phrase "unless otherwise specified" applies to cases such as the swappable with requirements ([swappable.requirements]). The exception for overloaded operators allowsis intended to allow argument-dependent lookup in cases like that of ostream_iterator::operator= (24.6.2.2):

    Effects:

    *out_stream << value;
    if (delim != 0)
      *out_stream << delim ;
    return *this;
    

    end note]

Date: 2016-11-15.00:00:00

[ 2016-11-10, Tim Song comments ]

The "non-operator" seems to have been added at the wrong spot. The problem at issue is permission to call operator functions found via ADL, not permission for operator functions in the standard library to ADL all over the place. The problem is not unique to operator functions in the standard library — a significant portion of <algorithm> and <numeric> uses some operator (==, <, +, *, etc.) that may be picked up via ADL.

There is also an existing problem in that the example makes no sense anyway: the constraint in this paragraph only applies to non-members, yet ostream_iterator::operator= is a member function.

Date: 2016-11-15.00:00:00

[ 2016-11-09, Jonathan comments and provides wording ]

The current wording was added by DR 225.

Date: 2016-11-09.00:00:00

Addresses GB 39

The example is supposed to highlight the 'otherwise specified' aspect of invoking ADL, yet there is no such specification. It is unlikely that we intend to explicitly qualify calls to operator functions, so they probably should be exempted from this restriction.

Suggested resolution:

Fix example (and referenced clause) to specify use of ADL, or exempt operators from this clause, and find a better example, probably using swap.

History
Date User Action Args
2017-07-30 20:15:43adminsetstatus: wp -> c++17
2017-03-05 23:41:16adminsetstatus: ready -> wp
2016-12-16 20:56:38adminsetmessages: + msg8725
2016-12-16 20:56:38adminsetstatus: new -> ready
2016-11-11 05:18:58adminsetmessages: + msg8625
2016-11-10 05:11:04adminsetmessages: + msg8605
2016-11-09 21:54:14adminsetmessages: + msg8598
2016-11-09 21:54:14adminsetmessages: + msg8597
2016-11-09 00:00:00admincreate