Title
Explicitly specifying template arguments for std::swap should not be supported
Status
new
Section
[namespace.std]
Submitter
Jiang An

Created on 2024-01-25.00:00:00 last changed 1 month ago

Messages

Date: 2024-03-15.00:00:00

[ 2024-03-15; Reflector poll ]

Set priority to 4 after reflector poll.

NAD - if a user does this and it breaks, so be it.

NAD as an issue creating a new kind of library policy for the first time. Needs a paper.

Not unique to std::swap. We should forbid this throughout the standard library.

Closely related to LWG 2146.

Date: 2024-01-25.00:00:00

std::swap overloads are separately declared in many standard library headers. It is likely expected that when a program includes correct headers for standard library types to be swapped, a std::swap call, with template argument deduced from arguments, selects the correct overload.

However, if one explicitly specifies template arguments for a std::swap call, there would be possibly undesired overloads for which templates arguments are fully obtained, and thus undesired instantiation and ill-formed may be triggered.

Perhaps we should explicitly state that explicitly specifying templates for std::swap is unsupported (having unspecified effects and possibly ill-formed), like taking address of non-address functions ([namespace.std]/6) and explicitly specifying template arguments for most standard algorithms ([algorithms.requirements]/15), to avoid possible reading that there are some guarantees, derived from signatures of overloads, for doing so.

History
Date User Action Args
2024-03-15 13:46:33adminsetmessages: + msg14015
2024-01-25 00:00:00admincreate