Skip to content

templated lambda, requires, __is_same and type traits #162092

@codethinki

Description

@codethinki

Somehow __is_same doesnt like type traits evaluated inside of it when in function instantiation context:

using type = std::vector<int>;
using inner = int;


template<class T>
concept range_value_int = std::same_as<std::ranges::range_value_t<T>, int>;

template<class T, auto Cpt>
concept generic_range_value = requires {
    Cpt.template operator()<std::ranges::range_value_t<T>>();
};

template<class T> requires generic_range_value<T, []<std::same_as<int>>() {}>
void z() {}

template<range_value_int T>
void y() {}

template<generic_range_value<[]<std::same_as<int>>() {}> T>
void x() {}


int main {
    static_assert(
        generic_range_value<type, []<std::same_as<int>>() {}>,
        "fuck"
    );

    y<type>();
    x<type>();
}

This does not compile and fails at the instantiation of "x" on the templated lambda operator call. it interestingly doesn't fail when calling it inside the static assert or when its evaluated in a requires clause behind the function.

msvc compiles it just fine.

version stuff:

clang version 20.1.8
Target: i686-pc-windows-msvc
Thread model: posix
InstalledDir: C:\Program Files\Microsoft Visual Studio\18\Insiders\VC\Tools\Llvm\bin

Metadata

Metadata

Assignees

No one assigned

    Labels

    clang:frontendLanguage frontend issues, e.g. anything involving "Sema"conceptsC++20 conceptslambdaC++11 lambda expressions

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions