31
|
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 |
// STLport regression testsuite component.
|
|
19 |
// To compile as a separate example, please #define MAIN.
|
|
20 |
|
|
21 |
#include <iostream>
|
|
22 |
#include <algorithm>
|
|
23 |
#include <iterator>
|
|
24 |
#include <functional>
|
|
25 |
|
|
26 |
#ifdef MAIN
|
|
27 |
#define ptrunf1_test main
|
|
28 |
#endif
|
|
29 |
bool even(int n_)
|
|
30 |
{
|
|
31 |
return(n_ % 2) == 0;
|
|
32 |
}
|
|
33 |
|
|
34 |
#if !defined (STLPORT) || defined(__STL_USE_NAMESPACES)
|
|
35 |
using namespace std;
|
|
36 |
#endif
|
|
37 |
int ptrunf1_test(int, char**)
|
|
38 |
{
|
|
39 |
cout<<"Results of ptrunf1_test:"<<endl;
|
|
40 |
|
|
41 |
int array [3] = { 1, 2, 3 };
|
|
42 |
|
|
43 |
int* p = find_if((int*)array, (int*)array + 3,
|
|
44 |
pointer_to_unary_function<int, bool>(even));
|
|
45 |
if(p != array + 3)
|
|
46 |
cout << *p << " is even" << endl;
|
|
47 |
|
|
48 |
if(2 !=*p)
|
|
49 |
return 1;
|
|
50 |
else
|
|
51 |
return 0;
|
|
52 |
}
|