31
|
1 |
|
|
2 |
|
|
3 |
// STLport regression testsuite component.
|
|
4 |
// To compile as a separate example, please #define MAIN.
|
|
5 |
|
|
6 |
#include <algorithm>
|
|
7 |
#include <iostream>
|
|
8 |
|
|
9 |
#ifdef MAIN
|
|
10 |
#define findif0_test main
|
|
11 |
#endif
|
|
12 |
static bool odd(int a_)
|
|
13 |
{
|
|
14 |
return a_ % 2;
|
|
15 |
}
|
|
16 |
|
|
17 |
#if !defined (STLPORT) || defined(__STL_USE_NAMESPACES)
|
|
18 |
using namespace std;
|
|
19 |
#endif
|
|
20 |
int findif0_test(int, char**)
|
|
21 |
{
|
|
22 |
cout<<"Results of findif0_test:"<<endl;
|
|
23 |
|
|
24 |
int numbers[6] = { 2, 4, 8, 15, 32, 64 };
|
|
25 |
|
|
26 |
int* location = find_if((int*)numbers, (int*)numbers + 6, odd);
|
|
27 |
if(location != numbers + 6)
|
|
28 |
cout
|
|
29 |
<< "Value "
|
|
30 |
<< *location
|
|
31 |
<< " at offset "
|
|
32 |
<<(location - numbers)
|
|
33 |
<< " is odd"
|
|
34 |
<< endl;
|
|
35 |
|
|
36 |
if((*location == 15) && ((location - numbers) == 3))
|
|
37 |
return 0;
|
|
38 |
else
|
|
39 |
return 1;
|
|
40 |
|
|
41 |
}
|