[dcl.fct.def.general] (original) (raw)

9 Declarations [dcl.dcl]

9.5 Function definitions [dcl.fct.def]

9.5.1 In general [dcl.fct.def.general]

A function shall be defined only in namespace or class scope.

The type of a parameter or the return type for a function definition shall not be a (possibly cv-qualified) class type that is incomplete or abstract within the function body unless the function is deleted ([dcl.fct.def.delete]).

[ Example

:

A simple example of a complete function definition is

int max(int a, int b, int c) { int m = (a > b) ? a : b; return (m > c) ? m : c; }

end example

]

[ Note

:

Unused parameters need not be named.

For example,

void print(int a, int) { std::printf("a = %d\n",a); }

end note

]

In the function-body, afunction-local predefined variable denotes a block-scope object of static storage duration that is implicitly defined (see [basic.scope.block]).

The function-local predefined variable __func__ is defined as if a definition of the form

static const char func[] = "function-name";

had been provided, where function-name is an implementation-defined string.

It is unspecified whether such a variable has an address distinct from that of any other object in the program.93

[ Example

:

struct S { S() : s(func) { } // OK const char* s; }; void f(const char* s = func); // error: func is undeclared

end example

]

Implementations are permitted to provide additional predefined variables with names that are reserved to the implementation ([lex.name]).

If a predefined variable is not odr-used ([basic.def.odr]), its string value need not be present in the program image.