Detailed Description
A ConvertibleToFunction is simply something which can be invoked using function notation - or something that boost::bind
can convert to a function. Specifically, a ConvertibleToFunction can be:
- A pointer to a function
- A pointer to a class or struct data member (argument is a pointer or a reference to a struct/class instance)
- A pointer to a class or struct member function (first argument is a pointer or a reference to a struct/class instance; Member function arguments follow in order)
- A
boost::reference_wrapper
to a ConvertibleToFunction
- A function object
Where functions are passed as template parameters in the Adobe Source Libraries, any ConvertibleToFunction may be used. The idea is that boost::bind(x, ...);
is a valid expression where ...
are arguments to x
. x
, in this case, is ConvertibleToFunction.
- Refinement Of:
- Associated Types:
- Notation:
F | A type that is a model of ConvertibleToFunction |
x1...xn | An optional argument list for the type that is a model of ConvertibleToFunction |
f | Object of type F |
- Definitions:
- Valid Expressions:
Name | Expression | Type requirements | Return type |
Convertible | boost::bind(&f, x1...xn); | | An invokable boost::function whose template argument is the function signature of f |
- Expression Semantics:
- Complexity Guarantees:
- Invariants:
- Type(s) Modeling this Concept:
- Anything that is acceptable to
boost::bind
.
- Example:
- Given a
vector
of structs...
struct my_struct { bool value_m; }
std::vector<my_struct> my_vector;
- Writing the following would be an error:
iter =
std::find_if(my_vector.begin(), my_vector.end(), &my_struct::value_m);
- But because a pointer to a member is ConvertibleToFunction, and in this case the function meets the requirements of a predicate (that is, the accessing of
value_m
will return either true
or false
) we can write:
iter =
adobe::find_if(my_vector.begin(), my_vector.end(), &my_struct::value_m);
- Further, because
vector
meets the requirements of a ConvertibleToRange, this can be shortened to:
-