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