struct SomeClass {
// void foo() & {std::cout << "Call on lvalue reference" << std::endl;} //1
void foo() const & {std::cout << "Call on const lvalue reference" << std::endl;} //2
void foo() && = delete; //3
void foo() const && {std::cout << "Call on const rvalue reference" << std::endl;} //4
};
int main() {
SomeClass lvalue;
lvalue.foo();
SomeClass{}.foo();
} Post #644
4.99K
Второй пошел
- 🔥 4
- 👍 3
- ❤ 2
- ⚡ 1