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

4277. §[algorithms.requirements] It is unclear what an algorithm is

Section: 26.2 [algorithms.requirements] Status: New Submitter: Jan Schultke Opened: 2025-06-08 Last modified: 2025-06-14

Priority: Not Prioritized

View other active issues in [algorithms.requirements].

View all other issues in [algorithms.requirements].

View all issues with New status.

Discussion:

26.2 [algorithms.requirements] paragraph 15 states:

The well-formedness and behavior of a call to an algorithm with an explicitly-specified template argument list is unspecified, except where explicitly stated otherwise.

It is unclear what this applies to because "algorithm" is never defined. 26.2 [algorithms.requirements] paragraph 1 uses the term while mentioning iterators and containers, but [algorithm] specifies function templates such as std::gcd which do not accept iterators.

The Remarks specifications in 26.8.9 [alg.min.max] providing exemptions from 26.2 [algorithms.requirements] paragraph 15 suggest that even function templates not accepting iterators are considered algorithms.

Proposed resolution:

This wording is relative to N5008.

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

    -15- The well-formedness and behavior of a call to an algorithma function template specified in Clause 26 [algorithms] (including call operators of algorithm function objects denoted as algorithms throughout Clause 26.2 [algorithms.requirements]) with an explicitly-specified template argument list is unspecified, except where explicitly stated otherwise.

    [Note 3: Consequently, an implementation can declare an algorithm with different template parameters than those presented. — end note]