Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Aug 12th, 2012  |  syntax: None  |  size: 0.31 KB  |  hits: 13  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1.  
  2. #include <utility>
  3.  
  4. class T {
  5.     T &operator=(const T&) = delete; // noncopyable
  6.     T(const T&) = delete; // noncopyable
  7. public:
  8.     T& operator=(T&&) = default; // moveable
  9.     T() = default; // default constructor
  10. };
  11.  
  12. T &&f() {
  13.     return std::move(T());
  14. }
  15.  
  16. int main() {
  17.     T t;
  18.     t = f();
  19. }