equal
deleted
inserted
replaced
|
1 /* |
|
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // STLport regression testsuite component. |
|
20 // To compile as a separate example, please #define MAIN. |
|
21 |
|
22 #include <algorithm> |
|
23 #include <iostream> |
|
24 |
|
25 #ifdef MAIN |
|
26 #define findif0_test main |
|
27 #endif |
|
28 static bool odd(int a_) |
|
29 { |
|
30 return a_ % 2; |
|
31 } |
|
32 |
|
33 #if !defined (STLPORT) || defined(__STL_USE_NAMESPACES) |
|
34 using namespace std; |
|
35 #endif |
|
36 int findif0_test(int, char**) |
|
37 { |
|
38 cout<<"Results of findif0_test:"<<endl; |
|
39 |
|
40 int numbers[6] = { 2, 4, 8, 15, 32, 64 }; |
|
41 |
|
42 int* location = find_if((int*)numbers, (int*)numbers + 6, odd); |
|
43 if(location != numbers + 6) |
|
44 cout |
|
45 << "Value " |
|
46 << *location |
|
47 << " at offset " |
|
48 <<(location - numbers) |
|
49 << " is odd" |
|
50 << endl; |
|
51 |
|
52 if((*location == 15) && ((location - numbers) == 3)) |
|
53 return 0; |
|
54 else |
|
55 return 1; |
|
56 |
|
57 } |