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-06-06

Priority: Not Prioritized

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).

Proposed resolution:

This wording is relative to N5008.

  1. 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 weakly_incrementable
          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]).