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.

4326. Standard defined queries can't customize forwarding_query_t by inheriting from it

Section: 33.5.1 [exec.fwd.env] Status: New Submitter: Lewis Baker Opened: 2025-08-25 Last modified: 2025-08-27

Priority: Not Prioritized

View all issues with New status.

Discussion:

The definition of the forwarding_query_t (33.5.1 [exec.fwd.env]) states that a query is a forwarding-query if either the expression q.query(forwarding_query) is a constant expression that evaluates to true or the query type inherits from forwarding_query_t.

However, all of the queries defined in 33 [exec] are defined similar to the following:

struct get_allocator_t { unspecified };

While this definition allows for the members of the class to be unspecified, it still explicitly specifies that it has an empty list of base-classes and therefore cannot customize forwarding_query_t by inheriting from forwarding_query_t.

We should consider whether we want to change the specification of queries that are to be forwarding-queries to allow inheritance from forwarding_query_t or otherwise remove the support for customizing forwarding_query_t by inheriting from it.

Proposed Approach:

Remove the rule that checks for inheritance from forwarding_query_t. Any query can already customize forwarding_query_t by defining a query(forwarding_query_t) member function, so there is no loss of functionality from doing this and it would simplify the design.

Proposed resolution:

This wording is relative to N5014.

  1. Modify 33.5.1 [exec.fwd.env] as indicated:

    -2- The name forwarding_query denotes a query object. For some query object q of type Q, forwarding_query(q) is expression-equivalent to:

    1. (2.1) — MANDATE-NOTHROW(q.query(forwarding_query)) if that expression is well-formed.

      Mandates: The expression above has type bool and is a core constant expression if q is a core constant expression.

    2. (2.2) — Otherwise, true if derived_from<Q, forwarding_query_t> is true.

    3. (2.3) — Otherwise, false.