Instigate Open Source Documentation

instigate::stl::binary_function::interface< BF > Struct Template Reference

Interface of the Binary Function Concept. More...

#include <_binary_function.hpp>

Inheritance diagram for instigate::stl::binary_function::interface< BF >:

instigate::generic::assignable::interface< BF >

List of all members.

Public Types

typedef BF::first_argument_type first_argument_type
 The type of the binary_function's first argument.
typedef BF::second_argument_type second_argument_type
 The type of the binary_function second argument.
typedef BF::result_type result_type
 The type returned when the binary_function is called.

Static Public Member Functions

static result_type invoke (const BF &f, first_argument_type a1, second_argument_type a2)
 Invoke the function on given arguments.


Detailed Description

template<typename BF>
struct instigate::stl::binary_function::interface< BF >

Interface of the Binary Function Concept.

The binary_function is a correspondence between pair of argument values and a result value. I.e. for each pair of argument values it should be possible to invoke the function and obtain the corresponding result value.

Ideally, invocation should have constant time complexity. Although the existing STL algorithms that use this concept are applicable even if the functions have higher complexity, but using them with functions that are not constant time invalidates the complexity guarantee of the algorithm.

This corresponds to SGI STL's concept Adaptable binary_function because we require information about argument type and result type. Thus, all binary functions in Instigate STL are adaptable, including plain C functions.

Note:
It is under user's responsibility, to define associated types (i.e. first_argument_type, second_argument_type and result_type) in such way, that temporary objects will not be created by the compiler upon passing arguments and returning value, e.g. arguments can be passed by reference or const reference.
This is a "non-intrusive" interface of the binary_function, which does not impose any syntactical constraints on the Model. E.g. we do not require it to redefine operator() as in Standard. Any type that conceptually can be treated as a binary function can become a model of this concept, if this interface is provided for it by specializing this template structure with that type and providing definitions for associated types and basic operations.

Remarks:
The default implementation is using ANSI STL syntax, therefore any standard Adaptable binary_functor is also a model of this concept.

Member Function Documentation

template<typename BF>
static result_type instigate::stl::binary_function::interface< BF >::invoke ( const BF &  f,
first_argument_type  a1,
second_argument_type  a2 
) [inline, static]

Invoke the function on given arguments.

Parameters:
f - the binary function
a1 - the first argument
a2 - the second argument
Returns:
The result of the invocation of f on (a1, a2)
Remarks:
f should be stateless, i.e. caller should not rely on state changes to have impact on f.

Referenced by instigate::stl::binary_function::requirements< T >::helper(), and instigate::stl::invoke().


The documentation for this struct was generated from the following file:


© Instigate CJSC, Open Source