fork(1) download
  1. #include <iostream>
  2. #include <utility>
  3.  
  4. class test
  5. {
  6. private:
  7. test() { }
  8. public:
  9. test foo() { return *this; }
  10.  
  11. static const char *name() { return "test"; }
  12. };
  13.  
  14. int main()
  15. {
  16. std::cout << decltype(test().foo())::name() << std::endl; // 1
  17. std::cout << decltype(std::declval<test>().foo())::name() << std::endl; // 2
  18. }
  19.  
Success #stdin #stdout 0s 3340KB
stdin
Standard input is empty
stdout
test
test