Adobe Source Libraries 1.49.0
A collection of C++ libraries.
Loading...
Searching...
No Matches
ConvertibleToFunction
Description
A ConvertibleToFunction is simply something which can be invoked using function notation - or something that std::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 std::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 std::bind(x, ...); is a valid expression where ... are arguments to x. x, in this case, is ConvertibleToFunction.

Refinement Of
Associated Type(s)
Notation
FA type that is a model of ConvertibleToFunction
x1...xnAn optional argument list for the type that is a model of ConvertibleToFunction
fObject of type F
Definitions
Valid Expressions
NameExpressionType requirementsReturn type
Convertiblestd::bind(&f, x1...xn); An invokable std::function whose template argument is the function signature of f
Expression Semantics
Complexity Guarantee(s)
Invariants
Type(s) Modeling this Concept
  • Anything that is acceptable to std::bind.
Example
Given a vector of structs...
struct my_struct { bool value_m; }
std::vector<my_struct> my_vector;
// Code here to fill the vector with some bools...
Writing the following would be an error:
iter = std::find_if(my_vector.begin(), my_vector.end(), &my_struct::value_m); // Error!
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); // works!
InputIterator find_if(InputIterator first, InputIterator last, Predicate pred)
find implementation
Definition find.hpp:165
Further, because vector meets the requirements of a ConvertibleToRange, this can be shortened to:
iter = adobe::find_if(my_vector, &my_struct::value_m); // also works!