template<typename Functor, class AttributeCopier = GeneralBinaryAttributeCopier, template< typename, typename, typename, typename > class FunctorWrapper = BinaryNAPropagator>
class CXXR::VectorOps::BinaryFunction< Functor, AttributeCopier, FunctorWrapper >
Class used to apply a binary function to vectors.
An object of this class is used to create a vector from two others (the operands); the operands must be conformable as tested by checkOperandsConformable().
If either operand has size zero then the result will have size zero. Otherwise, the result will have the same number of elements as the larger of the operands, and each element of the result is obtained by applying the binary function to the corresponding elements of the two operands (treating them for this purpose as vectors). If the operands are of unequal length, the elements in the shorter operand are recycled as necessary; in this case a warning is raised if shorter operand has non-zero length but its length is not an exact submultiple of the length of the longer operand.
- Template Parameters:
-
Functor | Function or function object type, representing a binary function. |
AttributeCopier | This class must define a static member function with the signature copyAttributes(VectorBase* vout, const VectorBase* vl, const VectorBase* vr) . (Its return value, if any, is ignored.) The apply() method of BinaryFunction will invoke this member function to copy attributes from the operands vl and vr of the binary function to its result vout . See the description of VectorOps::GeneralBinaryAttributeCopier for a commonly used example (in fact, the default). |
FunctorWrapper | Each invocation of apply() will create an object of class FunctorWrapper<Functor>, and delegate to it the task of calling the binary function; the FunctorWrapper objects can then monitor any special conditions. See the description of VectorOps::BinaryNAPropagator for further information. |
template<typename Functor , class AttributeCopier , template< typename, typename, typename, typename > class FunctorWrapper>
template<class Vout , class Vl , class Vr >
Apply a binary function to a vector.
- Template Parameters:
-
Vout | Class of vector to be produced as a result. It must be possible to assign values of the return type of f to the elements of a vector of type Vout . |
Vl | Class of vector forming the first operand. It must be possible implicitly to convert the element data type of Vl to the type of the first argument of f . |
Vr | Class of vector forming the second operand. It must be possible implicitly to convert the element data type of Vr to the type of the second argument of f . |
- Parameters:
-
vl | Non-null pointer to the first operand. |
vr | Non-null pointer to the second operand. |
- Returns:
- Pointer to the result vector.