Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

why isn't it "auto this"? That that would make it <type> <name> like everything else in the language


The name is "self" not "this". "this" is a keyword indicating it's the explicit object parameter, it's not even actually a type.

C++ seems to be trying to maximise confusion these days.


  struct foo
  {
    void bar(int a, int b) {
      auto lambda = [&] (auto this self) { 
        this->compute();
      };
    }

    void compute();
  };

if the variable name was "auto this" you wouldn't be able to refer to "compute" through the "this" of the parent class here




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: