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() && {std::cout << "Call on rvalue reference" << std::endl;} //3
void foo() const && = delete; //4
};
int main() {
SomeClass lvalue;
lvalue.foo();
SomeClass{}.foo();
} Post #638
4.32K
Третий пошел
- 🔥 9
- ⚡ 1
- 👍 1