Title
Is a closure type from a lambda-expression appearing in a concept-definition a TU-local entity?
Status
open
Section
6.6 [basic.link]
Submitter
Jason Merrill

Created on 2025-01-24.00:00:00 last changed 1 week ago

Messages

Date: 2025-01-24.16:46:25

Suggested resolution:

Change in 6.6 [basic.link] paragraph 15.2 as follows:

An entity is TU-local if it is
  • a type, function, variable, or template that
    • has a name with internal linkage, or
    • does not have a name with linkage and is declared, or introduced by a lambda-expression, within the definition of a TU-local entity,
  • a type with no name that is defined outside a class-specifier, function body, concept-definition, or initializer or is introduced by a defining-type-specifier that is used to declare only TU-local entities,
  • ...
Date: 2025-01-24.00:00:00

Consider:

   template<typename _Tp>
    concept __is_derived_from_optional = requires (const _Tp& __t) {
     []<typename _Up>(const optional<_Up>&){ }(__t);
    };

According to 6.6 [basic.link] paragraph 15, the closure type of the lambda-expression is a TU-local entity, thus the concept is an exposure, thus it cannot appear in a module interface unit. There is no fundamental reason why this needs to be the case.

History
Date User Action Args
2025-01-24 16:46:25adminsetmessages: + msg7955
2025-01-24 00:00:00admincreate