This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of WP status.

### 3419. §[algorithms.requirements]/15 doesn't reserve as many rights as it intends to

Section: 27.2 [algorithms.requirements] Status: WP Submitter: Richard Smith Opened: 2020-03-24 Last modified: 2020-11-09

Priority: 0

View all other issues in [algorithms.requirements].

View all issues with WP status.

Discussion:

27.2 [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.

[2020-04-04 Issue Prioritization]

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

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

Proposed resolution:

This wording is relative to N4861.

1. Modify 27.2 [algorithms.requirements] as indicated:

   > -15- The well-formedness and behavior of a call to an algorithm with an explicitly-specified template argument list is number 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 presented the algorithms may not be called with explicitly-specified template argument lists. — end note]