From Jason Turner

[dcl.meaning]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpxl00m0tu/{from.md → to.md} +113 -112
tmp/tmpxl00m0tu/{from.md → to.md} RENAMED
@@ -2,32 +2,26 @@
2
 
3
  A list of declarators appears after an optional (Clause  [[dcl.dcl]])
4
  *decl-specifier-seq* ([[dcl.spec]]). Each declarator contains exactly
5
  one *declarator-id*; it names the identifier that is declared. An
6
  *unqualified-id* occurring in a *declarator-id* shall be a simple
7
- *identifier* except for the declaration of some special functions (
8
- [[class.conv]], [[class.dtor]], [[over.oper]]) and for the declaration
9
- of template specializations or partial specializations ([[temp.spec]]).
10
- A *declarator-id* shall not be qualified except for the definition of a
11
- member function ([[class.mfct]]) or static data member (
12
- [[class.static]]) outside of its class, the definition or explicit
13
- instantiation of a function or variable member of a namespace outside of
14
- its namespace, or the definition of an explicit specialization outside
15
- of its namespace, or the declaration of a friend function that is a
16
- member of another class or namespace ([[class.friend]]). When the
17
- *declarator-id* is qualified, the declaration shall refer to a
18
- previously declared member of the class or namespace to which the
19
- qualifier refers (or, in the case of a namespace, of an element of the
20
- inline namespace set of that namespace ([[namespace.def]])) or to a
21
- specialization thereof; the member shall not merely have been introduced
22
- by a *using-declaration* in the scope of the class or namespace
23
- nominated by the *nested-name-specifier* of the *declarator-id*. The
24
- *nested-name-specifier* of a qualified *declarator-id* shall not begin
25
- with a *decltype-specifier*. If the qualifier is the global `::` scope
26
- resolution operator, the *declarator-id* refers to a name declared in
27
- the global namespace scope. The optional *attribute-specifier-seq*
28
- following a *declarator-id* appertains to the entity that is declared.
29
 
30
  A `static`, `thread_local`, `extern`, `register`, `mutable`, `friend`,
31
  `inline`, `virtual`, or `typedef` specifier applies directly to each
32
  *declarator-id* in an *init-declarator-list*; the type specified for
33
  each *declarator-id* depends on both the *decl-specifier-seq* and its
@@ -139,13 +133,15 @@ cv-unqualified pointer later, for example:
139
  *p = 5; // clobber ci
140
  ```
141
 
142
  See also  [[expr.ass]] and  [[dcl.init]].
143
 
144
- There are no pointers to references; see  [[dcl.ref]]. Since the address
145
- of a bit-field ([[class.bit]]) cannot be taken, a pointer can never
146
- point to a bit-field.
 
 
147
 
148
  ### References <a id="dcl.ref">[[dcl.ref]]</a>
149
 
150
  In a declaration `T` `D` where `D` has either of the forms
151
 
@@ -156,13 +152,13 @@ In a declaration `T` `D` where `D` has either of the forms
156
 
157
  and the type of the identifier in the declaration `T` `D1` is “ `T`,”
158
  then the type of the identifier of `D` is “ reference to `T`.” The
159
  optional *attribute-specifier-seq* appertains to the reference type.
160
  Cv-qualified references are ill-formed except when the cv-qualifiers are
161
- introduced through the use of a typedef ([[dcl.typedef]]) or of a
162
- template type argument ([[temp.arg]]), in which case the cv-qualifiers
163
- are ignored.
164
 
165
  ``` cpp
166
  typedef int& A;
167
  const A aref = 3; // ill-formed; lvalue reference to non-const initialized with rvalue
168
  ```
@@ -232,20 +228,20 @@ contains an explicit `extern` specifier ([[dcl.stc]]), is a class
232
  member ([[class.mem]]) declaration within a class definition, or is the
233
  declaration of a parameter or a return type ([[dcl.fct]]); see 
234
  [[basic.def]]. A reference shall be initialized to refer to a valid
235
  object or function. in particular, a null reference cannot exist in a
236
  well-defined program, because the only way to create such a reference
237
- would be to bind it to the “object” obtained by dereferencing a null
238
- pointer, which causes undefined behavior. As described in 
239
  [[class.bit]], a reference cannot be bound directly to a bit-field.
240
 
241
- If a typedef ([[dcl.typedef]]), a type *template-parameter* (
242
- [[temp.arg.type]]), or a *decltype-specifier* ([[dcl.type.simple]])
243
- denotes a type `TR` that is a reference to a type `T`, an attempt to
244
- create the type “lvalue reference to cv `TR`” creates the type “lvalue
245
- reference to `T`”, while an attempt to create the type “rvalue reference
246
- to cv `TR`” creates the type `TR`.
247
 
248
  ``` cpp
249
  int i;
250
  typedef int& LRI;
251
  typedef int&& RRI;
@@ -259,10 +255,13 @@ RRI&& r5 = 5; // r5 has the type int&&
259
 
260
  decltype(r2)& r6 = i; // r6 has the type int&
261
  decltype(r2)&& r7 = i; // r7 has the type int&
262
  ```
263
 
 
 
 
264
  ### Pointers to members <a id="dcl.mptr">[[dcl.mptr]]</a>
265
 
266
  In a declaration `T` `D` where `D` has the form
267
 
268
  ``` bnf
@@ -326,24 +325,25 @@ and the type of the identifier in the declaration `T` `D1` is
326
  “*derived-declarator-type-list* `T`”, then the type of the identifier of
327
  `D` is an array type; if the type of the identifier of `D` contains the
328
  `auto` , the program is ill-formed. `T` is called the array *element
329
  type*; this type shall not be a reference type, the (possibly
330
  cv-qualified) type `void`, a function type or an abstract class type. If
331
- the *constant-expression* ([[expr.const]]) is present, it shall be an
332
- integral constant expression and its value shall be greater than zero.
333
- The constant expression specifies the *bound* of (number of elements in)
334
- the array. If the value of the constant expression is `N`, the array has
335
- `N` elements numbered `0` to `N-1`, and the type of the identifier of
336
- `D` is “ array of `N` `T`”. An object of array type contains a
337
- contiguously allocated non-empty set of `N` subobjects of type `T`.
338
- Except as noted below, if the constant expression is omitted, the type
339
- of the identifier of `D` is “ array of unknown bound of `T`”, an
340
- incomplete object type. The type “ array of `N` `T`” is a different type
341
- from the type “ array of unknown bound of `T`”, see  [[basic.types]].
342
- Any type of the form “ array of `N` `T`” is adjusted to “array of `N`
343
- `T`”, and similarly for “array of unknown bound of `T`”. The optional
344
- *attribute-specifier-seq* appertains to the array.
 
345
 
346
  ``` cpp
347
  typedef int A[5], AA[2][3];
348
  typedef const A CA; // type is ``array of 5 const int''
349
  typedef const AA CAA; // type is ``array of 2 array of 3 const int''
@@ -472,11 +472,11 @@ and the type of the contained *declarator-id* in the declaration `T`
472
  “*derived-declarator-type-list* function of
473
  (*parameter-declaration-clause*) *cv-qualifier-seq*
474
  *ref-qualifier*returning *trailing-return-type*”. The optional
475
  *attribute-specifier-seq* appertains to the function type.
476
 
477
- A type of either form is a *function type*.[^10]
478
 
479
  ``` bnf
480
  parameter-declaration-clause:
481
  parameter-declaration-listₒₚₜ ...ₒₚₜ
482
  parameter-declaration-list ',' ...
@@ -502,18 +502,18 @@ appertains to the parameter.
502
  The *parameter-declaration-clause* determines the arguments that can be
503
  specified, and their processing, when the function is called. the
504
  *parameter-declaration-clause* is used to convert the arguments
505
  specified on the function call; see  [[expr.call]]. If the
506
  *parameter-declaration-clause* is empty, the function takes no
507
- arguments. The parameter list `(void)` is equivalent to the empty
508
- parameter list. Except for this special case, `void` shall not be a
509
- parameter type (though types derived from `void`, such as `void*`, can).
510
- If the *parameter-declaration-clause* terminates with an ellipsis or a
511
- function parameter pack ([[temp.variadic]]), the number of arguments
512
- shall be equal to or greater than the number of parameters that do not
513
- have a default argument and are not function parameter packs. Where
514
- syntactically correct and where “” is not part of an
515
  *abstract-declarator*, “” is synonymous with “”. the declaration
516
 
517
  ``` cpp
518
  int printf(const char*, ...);
519
  ```
@@ -547,20 +547,31 @@ presence or absence of the ellipsis or a function parameter pack is the
547
  function’s *parameter-type-list*. This transformation does not affect
548
  the types of the parameters. For example,
549
  `int(*)(const int p, decltype(p)*)` and `int(*)(int, const int*)` are
550
  identical types.
551
 
552
- A *cv-qualifier-seq* or a *ref-qualifier* shall only be part of:
 
 
553
 
554
  - the function type for a non-static member function,
555
  - the function type to which a pointer to member refers,
556
  - the top-level function type of a function typedef declaration or
557
  *alias-declaration*,
558
  - the *type-id* in the default argument of a *type-parameter* (
559
  [[temp.param]]), or
560
  - the *type-id* of a *template-argument* for a *type-parameter* (
561
- [[temp.names]]).
 
 
 
 
 
 
 
 
 
562
 
563
  The effect of a *cv-qualifier-seq* in a function declarator is not the
564
  same as adding cv-qualification on top of the function type. In the
565
  latter case, the cv-qualifiers are ignored. a function type that has a
566
  *cv-qualifier-seq* is not a cv-qualified type; there are no cv-qualified
@@ -589,20 +600,21 @@ int fseek(FILE*, long, int);
589
  declares a function taking three arguments of the specified types, and
590
  returning `int` ([[dcl.type]]).
591
 
592
  If the type of a parameter includes a type of the form “pointer to array
593
  of unknown bound of `T`” or “reference to array of unknown bound of
594
- `T`,” the program is ill-formed.[^11] Functions shall not have a return
595
  type of type array or function, although they may have a return type of
596
  type pointer or reference to such things. There shall be no arrays of
597
  functions, although there can be arrays of pointers to functions.
598
 
599
  Types shall not be defined in return or parameter types. The type of a
600
  parameter or the return type for a function definition shall not be an
601
- incomplete class type (possibly cv-qualified) unless the function
602
- definition is nested within the *member-specification* for that class
603
- (including definitions in nested classes defined within the class).
 
604
 
605
  A typedef of function type may be used to declare a function but shall
606
  not be used to define a function ([[dcl.fct.def]]).
607
 
608
  ``` cpp
@@ -610,34 +622,18 @@ typedef void F();
610
  F fv; // OK: equivalent to void fv();
611
  F fv { } // ill-formed
612
  void fv() { } // OK: definition of fv
613
  ```
614
 
615
- A typedef of a function type whose declarator includes a
616
- *cv-qualifier-seq* shall be used only to declare the function type for a
617
- non-static member function, to declare the function type to which a
618
- pointer to member refers, or to declare the top-level function type of
619
- another function typedef declaration.
620
-
621
- ``` cpp
622
- typedef int FIC(int) const;
623
- FIC f; // ill-formed: does not declare a member function
624
- struct S {
625
- FIC f; // OK
626
- };
627
- FIC S::*pm = &S::f; // OK
628
- ```
629
-
630
  An identifier can optionally be provided as a parameter name; if present
631
- in a function definition ([[dcl.fct.def]]), it names a parameter
632
- (sometimes called “formal argument”). In particular, parameter names are
633
- also optional in function definitions and names used for a parameter in
634
- different declarations and the definition of a function need not be the
635
- same. If a parameter name is present in a function declaration that is
636
- not a definition, it cannot be used outside of its function declarator
637
- because that is the extent of its potential scope (
638
- [[basic.scope.proto]]).
639
 
640
  the declaration
641
 
642
  ``` cpp
643
  int i,
@@ -671,11 +667,11 @@ IFUNC* fpif(int);
671
  ```
672
 
673
  or
674
 
675
  ``` cpp
676
- auto fpif(int)->int(*)(int)
677
  ```
678
 
679
  A *trailing-return-type* is most useful for a type that would be more
680
  complicated to specify before the *declarator-id*:
681
 
@@ -687,10 +683,13 @@ rather than
687
 
688
  ``` cpp
689
  template <class T, class U> decltype((*(T*)0) + (*(U*)0)) add(T t, U u);
690
  ```
691
 
 
 
 
692
  A *declarator-id* or *abstract-declarator* containing an ellipsis shall
693
  only be used in a *parameter-declaration*. Such a
694
  *parameter-declaration* is a parameter pack ([[temp.variadic]]). When
695
  it is part of a *parameter-declaration-clause*, the parameter pack is a
696
  function parameter pack ([[temp.variadic]]). Otherwise, the
@@ -710,13 +709,13 @@ void g() {
710
  ```
711
 
712
  There is a syntactic ambiguity when an ellipsis occurs at the end of a
713
  *parameter-declaration-clause* without a preceding comma. In this case,
714
  the ellipsis is parsed as part of the *abstract-declarator* if the type
715
- of the parameter names a template parameter pack that has not been
716
- expanded; otherwise, it is parsed as part of the
717
- *parameter-declaration-clause*.[^12]
718
 
719
  ### Default arguments <a id="dcl.fct.default">[[dcl.fct.default]]</a>
720
 
721
  If an *initializer-clause* is specified in a *parameter-declaration*
722
  this *initializer-clause* is used as a default argument. Default
@@ -742,11 +741,11 @@ A default argument shall be specified only in the
742
  *parameter-declaration-clause* of a function declaration or in a
743
  *template-parameter* ([[temp.param]]); in the latter case, the
744
  *initializer-clause* shall be an *assignment-expression*. A default
745
  argument shall not be specified for a parameter pack. If it is specified
746
  in a *parameter-declaration-clause*, it shall not occur within a
747
- *declarator* or *abstract-declarator* of a *parameter-declaration*.[^13]
748
 
749
  For non-template functions, default arguments can be added in later
750
  declarations of a function in the same scope. Declarations in different
751
  scopes have completely distinct sets of default arguments. That is,
752
  declarations in inner scopes do not acquire default arguments from
@@ -785,20 +784,19 @@ accumulated sets of default arguments at the end of the translation
785
  units shall be the same; see  [[basic.def.odr]]. If a friend declaration
786
  specifies a default argument expression, that declaration shall be a
787
  definition and shall be the only declaration of the function or function
788
  template in the translation unit.
789
 
790
- A default argument is implicitly converted (Clause  [[conv]]) to the
791
- parameter type. The default argument has the same semantic constraints
792
- as the initializer in a declaration of a variable of the parameter type,
793
- using the copy-initialization semantics ([[dcl.init]]). The names in
794
- the default argument are bound, and the semantic constraints are
795
- checked, at the point where the default argument appears. Name lookup
796
- and checking of semantic constraints for default arguments in function
797
- templates and in member functions of class templates are performed as
798
- described in  [[temp.inst]]. in the following code, `g` will be called
799
- with the value `f(2)`:
800
 
801
  ``` cpp
802
  int a = 1;
803
  int f(int);
804
  int g(int x = f(a)); // default argument: f(::a)
@@ -817,13 +815,16 @@ up as described in  [[basic.lookup.unqual]]. Access checking applies to
817
  names in default arguments as described in Clause  [[class.access]].
818
 
819
  Except for member functions of class templates, the default arguments in
820
  a member function definition that appears outside of the class
821
  definition are added to the set of default arguments provided by the
822
- member function declaration in the class definition. Default arguments
823
- for a member function of a class template shall be specified on the
824
- initial declaration of the member function within the class template.
 
 
 
825
 
826
  ``` cpp
827
  class C {
828
  void f(int i = 3);
829
  void g(int i, int j = 99);
@@ -852,16 +853,16 @@ function.
852
  class A {
853
  void f(A* p = this) { } // error
854
  };
855
  ```
856
 
857
- Default arguments are evaluated each time the function is called. The
858
- order of evaluation of function arguments is unspecified. Consequently,
859
- parameters of a function shall not be used in a default argument, even
860
- if they are not evaluated. Parameters of a function declared before a
861
- default argument are in scope and can hide namespace and class member
862
- names.
863
 
864
  ``` cpp
865
  int a;
866
  int f(int a, int b = a); // error: parameter a
867
  // used as default argument
 
2
 
3
  A list of declarators appears after an optional (Clause  [[dcl.dcl]])
4
  *decl-specifier-seq* ([[dcl.spec]]). Each declarator contains exactly
5
  one *declarator-id*; it names the identifier that is declared. An
6
  *unqualified-id* occurring in a *declarator-id* shall be a simple
7
+ *identifier* except for the declaration of some special functions (
8
+ [[class.ctor]], [[class.conv]], [[class.dtor]], [[over.oper]]) and for
9
+ the declaration of template specializations or partial specializations (
10
+ [[temp.spec]]). When the *declarator-id* is qualified, the declaration
11
+ shall refer to a previously declared member of the class or namespace to
12
+ which the qualifier refers (or, in the case of a namespace, of an
13
+ element of the inline namespace set of that namespace (
14
+ [[namespace.def]])) or to a specialization thereof; the member shall not
15
+ merely have been introduced by a *using-declaration* in the scope of the
16
+ class or namespace nominated by the *nested-name-specifier* of the
17
+ *declarator-id*. The *nested-name-specifier* of a qualified
18
+ *declarator-id* shall not begin with a *decltype-specifier*. If the
19
+ qualifier is the global `::` scope resolution operator, the
20
+ *declarator-id* refers to a name declared in the global namespace scope.
21
+ The optional *attribute-specifier-seq* following a *declarator-id*
22
+ appertains to the entity that is declared.
 
 
 
 
 
 
23
 
24
  A `static`, `thread_local`, `extern`, `register`, `mutable`, `friend`,
25
  `inline`, `virtual`, or `typedef` specifier applies directly to each
26
  *declarator-id* in an *init-declarator-list*; the type specified for
27
  each *declarator-id* depends on both the *decl-specifier-seq* and its
 
133
  *p = 5; // clobber ci
134
  ```
135
 
136
  See also  [[expr.ass]] and  [[dcl.init]].
137
 
138
+ Forming a pointer to reference type is ill-formed; see  [[dcl.ref]].
139
+ Forming a pointer to function type is ill-formed if the function type
140
+ has *cv-qualifier*s or a *ref-qualifier*; see  [[dcl.fct]]. Since the
141
+ address of a bit-field ([[class.bit]]) cannot be taken, a pointer can
142
+ never point to a bit-field.
143
 
144
  ### References <a id="dcl.ref">[[dcl.ref]]</a>
145
 
146
  In a declaration `T` `D` where `D` has either of the forms
147
 
 
152
 
153
  and the type of the identifier in the declaration `T` `D1` is “ `T`,”
154
  then the type of the identifier of `D` is “ reference to `T`.” The
155
  optional *attribute-specifier-seq* appertains to the reference type.
156
  Cv-qualified references are ill-formed except when the cv-qualifiers are
157
+ introduced through the use of a *typedef-name* ([[dcl.typedef]],
158
+ [[temp.param]]) or *decltype-specifier* ([[dcl.type.simple]]), in which
159
+ case the cv-qualifiers are ignored.
160
 
161
  ``` cpp
162
  typedef int& A;
163
  const A aref = 3; // ill-formed; lvalue reference to non-const initialized with rvalue
164
  ```
 
228
  member ([[class.mem]]) declaration within a class definition, or is the
229
  declaration of a parameter or a return type ([[dcl.fct]]); see 
230
  [[basic.def]]. A reference shall be initialized to refer to a valid
231
  object or function. in particular, a null reference cannot exist in a
232
  well-defined program, because the only way to create such a reference
233
+ would be to bind it to the “object” obtained by indirection through a
234
+ null pointer, which causes undefined behavior. As described in 
235
  [[class.bit]], a reference cannot be bound directly to a bit-field.
236
 
237
+ If a *typedef-name* ([[dcl.typedef]], [[temp.param]]) or a
238
+ *decltype-specifier* ([[dcl.type.simple]]) denotes a type `TR` that is
239
+ a reference to a type `T`, an attempt to create the type “lvalue
240
+ reference to cv `TR`” creates the type “lvalue reference to `T`”, while
241
+ an attempt to create the type “rvalue reference to cv `TR`” creates the
242
+ type `TR`.
243
 
244
  ``` cpp
245
  int i;
246
  typedef int& LRI;
247
  typedef int&& RRI;
 
255
 
256
  decltype(r2)& r6 = i; // r6 has the type int&
257
  decltype(r2)&& r7 = i; // r7 has the type int&
258
  ```
259
 
260
+ Forming a reference to function type is ill-formed if the function type
261
+ has *cv-qualifier*s or a *ref-qualifier*; see  [[dcl.fct]].
262
+
263
  ### Pointers to members <a id="dcl.mptr">[[dcl.mptr]]</a>
264
 
265
  In a declaration `T` `D` where `D` has the form
266
 
267
  ``` bnf
 
325
  “*derived-declarator-type-list* `T`”, then the type of the identifier of
326
  `D` is an array type; if the type of the identifier of `D` contains the
327
  `auto` , the program is ill-formed. `T` is called the array *element
328
  type*; this type shall not be a reference type, the (possibly
329
  cv-qualified) type `void`, a function type or an abstract class type. If
330
+ the *constant-expression* ([[expr.const]]) is present, it shall be a
331
+ converted constant expression of type `std::size_t` and its value shall
332
+ be greater than zero. The constant expression specifies the *bound* of
333
+ (number of elements in) the array. If the value of the constant
334
+ expression is `N`, the array has `N` elements numbered `0` to `N-1`, and
335
+ the type of the identifier of `D` is “ array of `N` `T`”. An object of
336
+ array type contains a contiguously allocated non-empty set of `N`
337
+ subobjects of type `T`. Except as noted below, if the constant
338
+ expression is omitted, the type of the identifier of `D` is “ array of
339
+ unknown bound of `T`”, an incomplete object type. The type “ array of
340
+ `N` `T`” is a different type from the type “ array of unknown bound of
341
+ `T`”, see  [[basic.types]]. Any type of the form “ array of `N` `T`” is
342
+ adjusted to “array of `N` `T`”, and similarly for “array of unknown
343
+ bound of `T`”. The optional *attribute-specifier-seq* appertains to the
344
+ array.
345
 
346
  ``` cpp
347
  typedef int A[5], AA[2][3];
348
  typedef const A CA; // type is ``array of 5 const int''
349
  typedef const AA CAA; // type is ``array of 2 array of 3 const int''
 
472
  “*derived-declarator-type-list* function of
473
  (*parameter-declaration-clause*) *cv-qualifier-seq*
474
  *ref-qualifier*returning *trailing-return-type*”. The optional
475
  *attribute-specifier-seq* appertains to the function type.
476
 
477
+ A type of either form is a *function type*.[^9]
478
 
479
  ``` bnf
480
  parameter-declaration-clause:
481
  parameter-declaration-listₒₚₜ ...ₒₚₜ
482
  parameter-declaration-list ',' ...
 
502
  The *parameter-declaration-clause* determines the arguments that can be
503
  specified, and their processing, when the function is called. the
504
  *parameter-declaration-clause* is used to convert the arguments
505
  specified on the function call; see  [[expr.call]]. If the
506
  *parameter-declaration-clause* is empty, the function takes no
507
+ arguments. A parameter list consisting of a single unnamed parameter of
508
+ non-dependent type `void` is equivalent to an empty parameter list.
509
+ Except for this special case, a parameter shall not have type *cv*
510
+ `void`. If the *parameter-declaration-clause* terminates with an
511
+ ellipsis or a function parameter pack ([[temp.variadic]]), the number
512
+ of arguments shall be equal to or greater than the number of parameters
513
+ that do not have a default argument and are not function parameter
514
+ packs. Where syntactically correct and where “” is not part of an
515
  *abstract-declarator*, “” is synonymous with “”. the declaration
516
 
517
  ``` cpp
518
  int printf(const char*, ...);
519
  ```
 
547
  function’s *parameter-type-list*. This transformation does not affect
548
  the types of the parameters. For example,
549
  `int(*)(const int p, decltype(p)*)` and `int(*)(int, const int*)` are
550
  identical types.
551
 
552
+ A function type with a *cv-qualifier-seq* or a *ref-qualifier*
553
+ (including a type named by *typedef-name* ([[dcl.typedef]],
554
+ [[temp.param]])) shall appear only as:
555
 
556
  - the function type for a non-static member function,
557
  - the function type to which a pointer to member refers,
558
  - the top-level function type of a function typedef declaration or
559
  *alias-declaration*,
560
  - the *type-id* in the default argument of a *type-parameter* (
561
  [[temp.param]]), or
562
  - the *type-id* of a *template-argument* for a *type-parameter* (
563
+ [[temp.arg.type]]).
564
+
565
+ ``` cpp
566
+ typedef int FIC(int) const;
567
+ FIC f; // ill-formed: does not declare a member function
568
+ struct S {
569
+ FIC f; // OK
570
+ };
571
+ FIC S::*pm = &S::f; // OK
572
+ ```
573
 
574
  The effect of a *cv-qualifier-seq* in a function declarator is not the
575
  same as adding cv-qualification on top of the function type. In the
576
  latter case, the cv-qualifiers are ignored. a function type that has a
577
  *cv-qualifier-seq* is not a cv-qualified type; there are no cv-qualified
 
600
  declares a function taking three arguments of the specified types, and
601
  returning `int` ([[dcl.type]]).
602
 
603
  If the type of a parameter includes a type of the form “pointer to array
604
  of unknown bound of `T`” or “reference to array of unknown bound of
605
+ `T`,” the program is ill-formed.[^10] Functions shall not have a return
606
  type of type array or function, although they may have a return type of
607
  type pointer or reference to such things. There shall be no arrays of
608
  functions, although there can be arrays of pointers to functions.
609
 
610
  Types shall not be defined in return or parameter types. The type of a
611
  parameter or the return type for a function definition shall not be an
612
+ incomplete class type (possibly cv-qualified) unless the function is
613
+ deleted ([[dcl.fct.def.delete]]) or the definition is nested within the
614
+ *member-specification* for that class (including definitions in nested
615
+ classes defined within the class).
616
 
617
  A typedef of function type may be used to declare a function but shall
618
  not be used to define a function ([[dcl.fct.def]]).
619
 
620
  ``` cpp
 
622
  F fv; // OK: equivalent to void fv();
623
  F fv { } // ill-formed
624
  void fv() { } // OK: definition of fv
625
  ```
626
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
627
  An identifier can optionally be provided as a parameter name; if present
628
+ in a function definition ([[dcl.fct.def]]), it names a parameter. In
629
+ particular, parameter names are also optional in function definitions
630
+ and names used for a parameter in different declarations and the
631
+ definition of a function need not be the same. If a parameter name is
632
+ present in a function declaration that is not a definition, it cannot be
633
+ used outside of its function declarator because that is the extent of
634
+ its potential scope ([[basic.scope.proto]]).
 
635
 
636
  the declaration
637
 
638
  ``` cpp
639
  int i,
 
667
  ```
668
 
669
  or
670
 
671
  ``` cpp
672
+ auto fpif(int)->int(*)(int);
673
  ```
674
 
675
  A *trailing-return-type* is most useful for a type that would be more
676
  complicated to specify before the *declarator-id*:
677
 
 
683
 
684
  ``` cpp
685
  template <class T, class U> decltype((*(T*)0) + (*(U*)0)) add(T t, U u);
686
  ```
687
 
688
+ A *non-template function* is a function that is not a function template
689
+ specialization. A function template is not a function.
690
+
691
  A *declarator-id* or *abstract-declarator* containing an ellipsis shall
692
  only be used in a *parameter-declaration*. Such a
693
  *parameter-declaration* is a parameter pack ([[temp.variadic]]). When
694
  it is part of a *parameter-declaration-clause*, the parameter pack is a
695
  function parameter pack ([[temp.variadic]]). Otherwise, the
 
709
  ```
710
 
711
  There is a syntactic ambiguity when an ellipsis occurs at the end of a
712
  *parameter-declaration-clause* without a preceding comma. In this case,
713
  the ellipsis is parsed as part of the *abstract-declarator* if the type
714
+ of the parameter either names a template parameter pack that has not
715
+ been expanded or contains `auto`; otherwise, it is parsed as part of the
716
+ *parameter-declaration-clause*.[^11]
717
 
718
  ### Default arguments <a id="dcl.fct.default">[[dcl.fct.default]]</a>
719
 
720
  If an *initializer-clause* is specified in a *parameter-declaration*
721
  this *initializer-clause* is used as a default argument. Default
 
741
  *parameter-declaration-clause* of a function declaration or in a
742
  *template-parameter* ([[temp.param]]); in the latter case, the
743
  *initializer-clause* shall be an *assignment-expression*. A default
744
  argument shall not be specified for a parameter pack. If it is specified
745
  in a *parameter-declaration-clause*, it shall not occur within a
746
+ *declarator* or *abstract-declarator* of a *parameter-declaration*.[^12]
747
 
748
  For non-template functions, default arguments can be added in later
749
  declarations of a function in the same scope. Declarations in different
750
  scopes have completely distinct sets of default arguments. That is,
751
  declarations in inner scopes do not acquire default arguments from
 
784
  units shall be the same; see  [[basic.def.odr]]. If a friend declaration
785
  specifies a default argument expression, that declaration shall be a
786
  definition and shall be the only declaration of the function or function
787
  template in the translation unit.
788
 
789
+ The default argument has the same semantic constraints as the
790
+ initializer in a declaration of a variable of the parameter type, using
791
+ the copy-initialization semantics ([[dcl.init]]). The names in the
792
+ default argument are bound, and the semantic constraints are checked, at
793
+ the point where the default argument appears. Name lookup and checking
794
+ of semantic constraints for default arguments in function templates and
795
+ in member functions of class templates are performed as described in 
796
+ [[temp.inst]]. in the following code, `g` will be called with the value
797
+ `f(2)`:
 
798
 
799
  ``` cpp
800
  int a = 1;
801
  int f(int);
802
  int g(int x = f(a)); // default argument: f(::a)
 
815
  names in default arguments as described in Clause  [[class.access]].
816
 
817
  Except for member functions of class templates, the default arguments in
818
  a member function definition that appears outside of the class
819
  definition are added to the set of default arguments provided by the
820
+ member function declaration in the class definition; the program is
821
+ ill-formed if a default constructor ([[class.ctor]]), copy or move
822
+ constructor, or copy or move assignment operator ([[class.copy]]) is so
823
+ declared. Default arguments for a member function of a class template
824
+ shall be specified on the initial declaration of the member function
825
+ within the class template.
826
 
827
  ``` cpp
828
  class C {
829
  void f(int i = 3);
830
  void g(int i, int j = 99);
 
853
  class A {
854
  void f(A* p = this) { } // error
855
  };
856
  ```
857
 
858
+ A default argument is evaluated each time the function is called with no
859
+ argument for the corresponding parameter. The order of evaluation of
860
+ function arguments is unspecified. Consequently, parameters of a
861
+ function shall not be used in a default argument, even if they are not
862
+ evaluated. Parameters of a function declared before a default argument
863
+ are in scope and can hide namespace and class member names.
864
 
865
  ``` cpp
866
  int a;
867
  int f(int a, int b = a); // error: parameter a
868
  // used as default argument