Любые использование оператора по умолчанию! =, Оператор <...?C++

Программы на C++. Форум разработчиков
Anonymous
Любые использование оператора по умолчанию! =, Оператор <...?

Сообщение Anonymous »

Пусть упростите оператор == и Operator! = .
Если у меня есть ..struct S {
bool operator==(const S&) const = default;
// the line below not needed to do S{} != S{}
bool operator!=(const S&) const = default;
};

Если у меня нет .. operator == .. = default; затем добавление ..struct S {
// allowed - but it is deleted when neither operator defaulted nor operator== defined
bool operator!=(const S&) const = default;
};

S{} != S{}; // does not compile - operator!= is deleted

То же самое для оператора и All Operator

Подробнее здесь: https://stackoverflow.com/questions/796 ... r-operator

Вернуться в «C++»