Closed ranaanoop closed 4 months ago
I think the status quo is fine; we want ctors and dtors to be non-static member functions so that "this" works there. (There are other restrictions that prevent calls to e.g. constructors using class member access syntax.)
@jensmaurer I see. I was not aware(until I read the standard) that ctor are non-static member functions as most books that I've read did not mention this.
Full name of submitter: Anoop Rana
Reference (section label): [class.mem#general]
Link to reflector thread (if any): https://stackoverflow.com/questions/77968375/is-a-constructor-that-is-not-a-special-member-function-still-a-member-function
Issue description:
While answering this question on stackoverflow which basically wanted to know if all ctor are member functions, I noticed a possible defect afaik. In particular, I noted that [class.mem#general] says that:
And since a constructor is a member function(as explained here), the above seems to imply that a constructor is also considered to be a non-static member. So is this the intention(that is, is a ctor intended to be considered a non-static member).
Suggested resolution
Change [class.mem#general] to say:
Note the added exception for constructors and destructors in the above modified/updated/suggested resolution.