language: C++11 (gcc-4.7.2)
date: 516 days 2 hours ago
link:
visibility: public
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include <iostream>
 
struct X {
private:
X& operator=(X&) //no assignment
{return *this;}
X(X&){} //no copy
public:
X() {}
};
struct Y { X x; };
 
void f(X&){std::cout <<"one";}
void f(X&&){std::cout <<"two";}
 
template <typename T>
void g(T&& t) {
  f(std::forward<T>(t).x);
}
 
int main() {
    Y y;
    g(y);
}