https://godbolt.org/z/xYWbrvEPG
Код: Выделить всё
template
struct Reader {
friend consteval auto Get(Reader);
};
template
struct Writer {
friend consteval auto Get(Reader) { return U{}; }
};
auto Lambda = [] {};
template
struct Instance {
template
Instance(T) { }
void operator=(Instance const&) {}
};
int main() {
Instance first(5);
Instance second(1.2);
first = second;
}
Код: Выделить всё
: In instantiation of 'struct Writer':
:17:50: required by substitution of 'template Instance::Instance(T) [with T = Instance; auto = ]'
17 | template
| ^
:26:13: required from here
26 | first = second;
| ^~~~~~
:10:27: error: redefinition of 'consteval auto Get(Reader)'
10 | friend consteval auto Get(Reader) { return U{}; }
| ^~~
:10:27: note: 'consteval auto Get(Reader)' previously declared here
Если оператор= заменяется обычной функцией-членом, эта ошибка исчезает.
Подробнее здесь: https://stackoverflow.com/questions/798 ... r-template
Мобильная версия