Issue 4270: Diagnose misuse of std::projected::operator* (original) (raw)
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.
4270. Diagnose misuse of std::projected::operator*
Section: 24.3.6.4 [projected] Status: New Submitter: Jiang An Opened: 2025-05-30 Last modified: 2025-10-20
Priority: 3
View all other issues in [projected].
View all issues with New status.
Discussion:
std::projected::operator* is only intentionally used for type calculation like std::declval. Currently, if one attempts to call it in a potentially evaluated expression, the program is ill-formed, no diagnostic required because the operator* is not defined.
It seems better to diagnose such misuse, as we are already diagnosing misuse of std::declval(22.2.6 [declval]/2). Implementation used to perform such misuse via std::ranges::iter_move, but libc++ and libstdc++ have already switched not to do this (see microsoft/STL#5555).
[2025-10-20; Reflector poll.]
Set priority to 3 after reflector poll.
"NAD, the standard is clear that it can't be used."
Proposed resolution:
This wording is relative to N5008.
- Modify 24.3.6.4 [projected] as indicated:
namespace std {
template<class I, class Proj>
struct projected-impl { // exposition only
struct type { // exposition only
[…]
_// models weaklyincrementable_ indirect_result_t<Proj&, I> operator*() const; ~~_// not defined_~~};
};
[…]
}indirect_result_t<Proj&, I> operator*() const;
-?- Mandates: This function is not odr-used (6.3 [basic.def.odr]).