plus


A binary function object that returns the sum of its two operands.

Library

Standards<ToolKit>

Declaration


#include <functional>

template< class T >
struct plus : binary_function< T, T, T >

Interface

()
T operator()( const T& x , const T& y ) const
Returns x + y .
Example <ospace/osstd/examples/plus.cpp>
#include <iostream>
#include <functional>
#include <numeric>

int input1[ 4 ] = { 1, 6, 11, 8 };
int input2[ 4 ] = { 1, 5, 2, 3 };

void
main()
  {
  int total = inner_product
    (
    input1,
    input1 + 4,
    input2,
    0,
    plus< int >(),
    times< int >()
    );
  cout << "total = " << total << "\n";
  }

total = 77

Copyright©1994-2026 Recursion Software LLC
All Rights Reserved - For use by licensed users only.