Stefan said:
It once came to my mind that there are no functions, but just
- function definitions (in the source code),
- function declarations (in the source code),
- function call expressions (in the source code), and
- evaluation of function call expressions (at run time).
Sure there are functions. They are listed as a type of entity in clause 3.
The following conditions give birth to functions:
- Function definition that's not nested in a template-declaration.
- Instantiation of a function template or member function of a class
template or member function of a nested class of a class template.
- Explicit specializations where all template arguments are non-dependent.
I find it somewhat difficult to determine whether a member function of a
class template is itself a template or not. I think it is not a template
declaration, but it gives birth to a template entity, instead of a function.
When it is instantiated, a function is born.
So, i think one can differentiate between a syntactical function (function
declaration), and a semantical function (declaration that declares a
function) (the latter being the entity). The former for example applies to
function definitions nested in template-declarations (which are function-
declarations, but not functions).
You may compare it to object declarations. The following two are object
declarations. But the entity they declare are not objects, but are
references. The characteristic of an object declaration (which makes it
different from function declarations) is that they may have an initializer.
extern int &a [ = ... ];
extern int (&b)() [ = ... ];
In an example in 14.6.1.1/1 the Standard says about three function
declarations that they declare three function templates. The former is the
syntactical kind, and the latter is the semantical kind.
I think this can sometimes be confusing, though.
However, given an overloading, as in, say:
float cos( float );
long double cos( long double );
is this
- /one/ function »cos« with two different parameter lists, or
are these
- /two/ different functions »cos«, which happen to share the
same name?
These are two functions that share the same name. These are overloaded
declarations.