fork(2) download
  1. //Refer to: http://m...content-available-to-author-only...y.com/2013/06/03/overriding-the-broken-universal-reference-t/
  2. #include <iostream>
  3.  
  4. template<typename T>
  5. void apply( T&& value ) {
  6. std::cout << "apply" << std::endl;
  7. }
  8.  
  9. struct my_type { };
  10. void apply( my_type && value ) {
  11. std::cout << "my_type" << std::endl;
  12. }
  13.  
  14. int main() {
  15. apply( my_type() );
  16. my_type a;
  17. apply( a );
  18. apply( static_cast<my_type const>(a) );
  19. apply( static_cast<my_type const &>(a) );
  20. }
  21.  
Success #stdin #stdout 0s 2852KB
stdin
Standard input is empty
stdout
my_type
apply
apply
apply