os_replace |
Replaces a specified value in a sequence with another value.
A helper algorithm for replace()
. Replaces every occurrence of old in the container c
with new .
#include <ospace/helper/regalgo.h>
template< class Container, class T >
void os_replace( Container& c, const T& old, const T& new )
#include <iostream>
#include <vector>
#include <ospace/helper.h>
int numbers[ 6 ] = { 0, 1, 2, 0, 1, 2 };
void
main()
{
vector< int > v( numbers, numbers + 6 );
os_replace( v, 2, 42 );
for ( vector< int >::iterator i = v.begin(); i != v.end(); ++i )
cout << *i << ` `;
cout << "\n";
}
0 1 42 0 1 42
Copyright©1994-2026 Recursion
Software LLC
All Rights Reserved - For use by licensed users only.