modulus


A binary function object that returns its second operand in the modulus of the first operand.

Library

Standards<ToolKit>

Declaration


#include <functional>

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

Interface

()
T operator()( const T& x , const T& y ) const
Returns x % y .
Example <ospace/osstd/examples/modulus.cpp>
#include <algorithm>
#include <functional>

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

void
main()
  {
  int output[ 4 ];

  transform( input1, input1 + 4, input2, output, modulus< int >() );

  for ( int i = 0; i < 4; ++i )
    cout << output[ i ] << "\n";
  }

2
0
10
2

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