Closed
Description
See stack dump at https://godbolt.org/z/zeaqzTPjq. When the return type is the injected-class-name, its evaluation isn't considered a constant expression; see https://godbolt.org/z/zTEvYxx6x. GCC accepts them: https://godbolt.org/z/c7nq4dGE3, https://godbolt.org/z/YzaM56G1G.
mod.cpp
:
export module mod;
export template<typename StandardCharT, int N>
struct basic_symbol_text {
template<int N2>
constexpr friend basic_symbol_text operator+(
const basic_symbol_text&, const basic_symbol_text<char, N2>&) noexcept
{
return basic_symbol_text<StandardCharT, 1>{};
}
};
constexpr auto xxx = basic_symbol_text<char, 1>{} + basic_symbol_text<char, 1>{};
export module mod;
export template<typename StandardCharT, int N>
struct basic_symbol_text {
template<int N2>
constexpr friend basic_symbol_text operator+(
const basic_symbol_text&, const basic_symbol_text<char, N2>&) noexcept
{
return basic_symbol_text{};
}
};
constexpr auto xxx = basic_symbol_text<char, 1>{} + basic_symbol_text<char, 1>{};