Title
§[algorithms.requirements]/15 doesn't reserve as many rights as it intends to
Status
c++23
Section
[algorithms.requirements]
Submitter
Richard Smith

Created on 2020-03-24.00:00:00 last changed 5 months ago

Messages

Date: 2020-11-09.21:40:50

Proposed resolution:

This wording is relative to N4861.

  1. Modify [algorithms.requirements] as indicated:

    -15- The well-formedness and behavior of a call to an algorithm with an explicitly-specified template argument list isnumber and order of deducible template parameters for algorithm declarations are unspecified, except where explicitly stated otherwise. [Note: Consequently, an implementation can declare an algorithm with different template parameters than those presentedthe algorithms may not be called with explicitly-specified template argument lists. — end note]

Date: 2020-11-09.00:00:00

[ 2020-11-09 Approved In November virtual meeting. Status changed: Tentatively Ready → WP. ]

Date: 2020-04-04.00:00:00

[ 2020-04-04 Issue Prioritization ]

Status set to Tentatively Ready after six positive votes on the reflector.

Date: 2020-03-24.00:00:00

[algorithms.requirements]/15 says:

"The number and order of deducible template parameters for algorithm declarations are unspecified, except where explicitly stated otherwise. [Note: Consequently, the algorithms may not be called with explicitly-specified template argument lists. — end note]"

But the note doesn't follow from the normative rule. For example, we felt the need to explicitly allow deduction for min's template parameter:

template<typename T> const T& min(const T&, const T&);

… but if only the order and number of deducible template parameters is permitted to vary, then because of the required deduction behavior of this function template, there are only three possible valid declarations:

template<typename T> ??? min(const T&, const T&);
template<typename T, typename U> ??? min(const T&, const U&);
template<typename T, typename U> ??? min(const U&, const T&);

(up to minor differences in the parameter type). This doesn't prohibit calls with an explicitly-specified template argument list, contrary to the claim in the note. (Indeed, because a call such as min(1, {}) is valid, either the first of the above three overloads must be present or there must be a default template argument typename U = T, which further adds to the fact that there may be valid calls with an explicitly-specified template argument list.)

Also, the "explicitly stated otherwise" cases use phrasing such as: "An invocation may explicitly specify an argument for the template parameter T of the overloads in namespace std." which doesn't "specify otherwise" the normative rule, but does "specify otherwise" the claim in the note.

All this leads me to believe that [algorithms.requirements]/15 is backwards: the normative rule should be a note and the note should be the normative rule.

History
Date User Action Args
2023-11-22 15:47:43adminsetstatus: wp -> c++23
2020-11-09 21:40:50adminsetmessages: + msg11566
2020-11-09 21:40:50adminsetstatus: ready -> wp
2020-04-04 18:49:27adminsetmessages: + msg11188
2020-04-04 18:49:27adminsetstatus: new -> ready
2020-03-29 15:58:38adminsetmessages: + msg11179
2020-03-24 00:00:00admincreate