fork download
  1. #include <iostream>
  2.  
  3. template<typename T>
  4. T&& my_move(const T& t) noexcept {
  5. return std::move(const_cast<T&>(t));
  6. }
  7.  
  8. struct T
  9. {
  10. T() = default;
  11. T(const T&) { std::cout << "copy ctor\n"; }
  12. T(T&&) { std::cout << "move ctor\n"; }
  13. };
  14.  
  15. int main() {
  16. const T t;
  17. T a = my_move(t);
  18. }
  19.  
Success #stdin #stdout 0s 3296KB
stdin
Standard input is empty
stdout
move ctor