Boost Overload Terminology

Callable entities, functors, function objects are all terms used in C++ literature, however they are fuzzy because there is no shared definition: everyone uses these terms with a more strict or larger meaning. From this thought rises the need to formulate a clear and sensible definition for terms used in the boost overload documentation.

Function Objects

A type F is a model of class type function if F is a class that exposes a public function call operator. An instance of F is referred to as a function object.

A type F is a model of class type overloaded function if it is a model of class type function that owns two or more overloads of the function call operator. An instance of F is referred to as an overloaded function object.

A type F is a model of class type template function if it is a model of class type function that implements a template function call operator. An instance of F is referred to as a template function object.

A type F is a model of class type multi-signature function if it is a model of class type overloaded function or class type template function or both. An instance of F is referred to as a multi-signature function object.

Callable Entities and Signatures

We'll say that f is a callable entity if we can find an integer N >= 0 and N types A1, ..., AN such that the expression f(a1, ..., aN) is a correct expression for an ISO-compliant C++ compiler for any N-tuple (a1, ..., aN) where the object ai is of type Ai for i = 1,...,N. The expression f(a1, ..., aN) is referred to as a call to f. The type R (A1, ..., AN) is a supported signature of f, where, in case the expression f(a1, ..., aN) evaluates to an object r, R is the type of r, or if it doesn't evaluate to anything, R is the void type.

Given a signature S := R (A1, ..., AN) with N >= 0, the type Ai is said the i-th argument type of S and the type R is the return type of S, finally N is the arity of S.

If a callable entity supports only one signature these naming conventions extend naturally to the callable entity.

 

Examples of callable entities are:


Argument Binding

It is a technique to make up a new callable entity by binding one of the arguments of another callable entity to a fixed object.
Given an integer i > 0, an integer N >= i and a callable entity f with a supported signature R (A1, ..., AN) , once fixed an object t of type Ai we can define a new callable entity g that supports a signature R (A1, ..., ^Ai, ..., AN) with arity N-1 by setting g(a1, ..., ^ai, ..., aN) := f(a1, ..., t, ..., aN) for any (N-1)-tuple (a1, ..., ^ai, ..., aN) where t is placed at the i-th position and where the object ak is of type Ak for k = 1,..., ^i, ..., N. For the new callable entity produced by the binding will be used the notation  g := (f|i:t) .
( The notation x1, ..., ^xi, ..., xN is used to denote that the i-th term xi is erased from the list. )

Call Forwarding

Well' say that a callable entity f performs a forwarding call to a callable entity g if a call to f is equivalent to a call to g when the passed arguments are the same. In particular f has to return the same result returned by g and their return types have to be the same. If g doesn't return anything, f has to return nothing, too.

We'll say that a member function f of a class T performs a forwarding call to a callable entity g if for any object t of type T the callable entity t.f performs a forwarding call to g.

We'll say that a type T has access to a callable entity if it owns a method that performs a forwarding call to the given callable entity.

Member Functions

Signature
Generalizing we'll say that a member function f of a class T supports a signature S if given any object t of type T the callable entity t.f supports the signature S.

Explicit Signature
Given a non-const qualified member function f of a class T and that supports a signature R (A1, ..., AN) with N >= 0, we'll call an explicit signature of f the following signature:

Given a const qualified member function f of a class T and that supports a signature R (A1, ..., AN) with N >= 0, we'll call an explicit signature of f the following signature:

Call Forwarding
We'll say that a callable entity g performs a forwarding call to a non-const qualified member function f of a class T if the first argument type of g is T* and if for any object p of type T* the callable entity obtained by binding p to the first argument of g performs a forwarding call to the callable entity p->f.

We'll say that a callable entity g performs a forwarding call to a const qualified member function f of a class T if the first argument type of g is const T* and if for any object p of type T* or of type const T* the callable entity obtained binding p to the first argument of g performs a forwarding call to the callable entity p->f.

We'll say that a member function g of a class T performs a forwarding call to a member function f if for any object t of type T the callable entity t.g performs a forwarding call to f.

We'll say that a type T has access to a member function if it owns a method that is able to perform a forwarding call to the given member function.

Functors

A callable entity is said a functor if the variable entities that occur in its definition are objects.

Examples of functors are:


Dynamic Function Concept

A type F is a model of Dynamic Function with signature S if we have that :



The template class boost::function is a family of models of Dynamic Function.

Any instantiation of the template class overload that support one and only one signature is a model of Dynamic Function.


Dynamic Overloaded Function Concept

A type F is a model of Dynamic Overloaded Function supporting the signatures S1, ..., SN with N >= 2 if for each integer i s.t. 1 <= i <= N we have that :


 


Any instantiation of the template class overload that support more than one signature is a model of  Dynamic Overloaded Function.


Acknowledgements

Prepared by Marco Cecchetti (mrcekets@gmail.com)
Kindly revised by Dean Michael Berris (mikhailberis@gmail.com)
Released under the Boost Software License version 1.0 (http://boost.org/LICENSE_1_0.txt)
Date: November 5, 2007