Movatterモバイル変換


[0]ホーム

URL:


This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21 Core Issues List revision 119a. See http://www.open-std.org/jtc1/sc22/wg21/ for the official list.

2025-12-20


2430. Completeness of return and parameter types of member functions

Section:11.4  [class.mem]    Status:C++20    Submitter:Krystian Stasiowski    Date:2019-08-23

[Adopted as a DR at the November, 2019 meeting.]

According to 11.4 [class.mem] paragraph 7,

A class is considered a completely-defined object type(6.9 [basic.types]) (or complete type) at the closing} of theclass-specifier. The class is regarded ascomplete within its complete-class contexts; otherwise it isregarded as incomplete within its ownclassmember-specification.

The complete-class contexts (paragraph 6) include the bodyof a member function but not its return and parameter types.Thus it appears that an example like the following isill-formed:

  struct S {    S f(S s) { return s; }  };

because of 9.6.1 [dcl.fct.def.general] paragraph 2

The type of a parameter or the return type for a functiondefinition shall not be an incomplete or abstract (possiblycv-qualified) class type in the context of the functiondefinition unless the function is deleted(9.6.3 [dcl.fct.def.delete]).

The words “in the context of the functiondefinition” were added by the resolution ofissue 1824 to address thisproblem, but “context” is most naturallyread as referring to the lexical context where thedefinition appears rather than within its body.

Proposed resolution (October, 2019):

Change 9.6.1 [dcl.fct.def.general] paragraph 2 as follows:

...The type of a parameter or the return type for a functiondefinition shall not bean incomplete or abstract(possibly cv-qualified) class type in the context of thefunction definitiona (possibly cv-qualified)class type that is incomplete or abstract within thefunction body unless the function is deleted(9.6.3 [dcl.fct.def.delete]).



[8]ページ先頭

©2009-2026 Movatter.jp