What are the control qualifiers for functions?

According to this web page , a non-static member function can have a trailing &

or &&

in its declaration. They have the following example

struct S {
    virtual int f(char) const, g(int) &&; // declares two non-static member functions
    };

      

1) Does the signature of the second function sign virtual

?

virtual int g(int) &&

      

2) What is the meaning of the final &&

?

+3


source to share


1 answer


struct S {
  virtual int f(char) const, g(int) &&;
};

struct D : S {
  virtual int f(char) const override;
  virtual int g(int) && override;
};

      

the above code compiles in both g ++ and clang . This indicates, at least in practice, that g

virtual

in S

.



See What is an "rvalue reference for * this"? for your other question.

+6


source







All Articles