fork download
  1. #include <utility>
  2. #include <cstddef>
  3. #include <iostream>
  4.  
  5. using std::size_t;
  6.  
  7. template<class T>
  8. std::remove_cv_t<T> copy(T& t) {
  9. return t;
  10. }
  11. template<class T>
  12. void copy(T&&)=delete; // block rvalue copy
  13. template<class T, size_t N>
  14. void copy(T(&)[N]) = delete; // we can implement this if we want: see below
  15.  
  16. int main() {
  17. int x = 0;
  18. auto f = [&]() mutable {
  19. auto y = copy(x);
  20. std::cout << y << "\n";
  21. };
  22. f();
  23. }
Success #stdin #stdout 0s 3140KB
stdin
Standard input is empty
stdout
0