fork(1) download
  1. #include <functional>
  2.  
  3. void foo(int){}
  4.  
  5. int main(){
  6. // assume 'std::function' uses 'ArgTypes&&...' in 'operator()'
  7. std::function<void(int)> f(foo);
  8. // 'f's 'operator()' will be instantiated as
  9. // 'void operator()(int&&)'
  10. // which will only accept rvalues
  11. int i = 5;
  12. f(i); // error
  13. f(5); // OK, '5' is an rvalue
  14. }
Success #stdin #stdout 0s 2848KB
stdin
Standard input is empty
stdout
Standard output is empty