constexpr в объявлении дружественной функции
Код:
template<typename T>
class Foo;
template<typename T>
constexpr auto operator==(const Foo<T>& lhs, const Foo<T>& rhs) -> bool;
template<typename T>
class Foo
{
public:
friend constexpr auto operator==<T>(const Foo<T>&, const Foo<T>&) -> bool;
};
Нужно ли указывать constexpr в объявлении друга в данном случае? В стандарте нашел следующее:
When a friend declaration refers to a specialization of a function template, the function parameter declarations shall not include default arguments, nor shall the inline, constexpr, or consteval specifiers be used in such a declaration.
Однако, на том же cppreference, можно найти примеры с friend constexpr bool operator.., так что я не уверен, что правильно понял вышеприведенную выдержку из стандарта.
Ответы (1 шт):
В С++11 в этом случае нельзя использовать только inline спецификатор, а constexpr - можно.
8 When a friend declaration refers to a specialization of a function template, the function parameter declarations shall not include default arguments, nor shall the inline specifier be used in such a declaration.
А цитата из вопроса относится к 20 или 23 стандарту.