31
|
1 |
|
|
2 |
// STLport regression testsuite component.
|
|
3 |
// To compile as a separate example, please #define MAIN.
|
|
4 |
|
|
5 |
#include <algorithm>
|
|
6 |
#include <iostream>
|
|
7 |
#include <cstring>
|
|
8 |
|
|
9 |
#ifdef MAIN
|
|
10 |
#define maxelem2_test main
|
|
11 |
#endif
|
|
12 |
|
|
13 |
#if !defined (STLPORT) || defined(__STL_USE_NAMESPACES)
|
|
14 |
using namespace std;
|
|
15 |
#endif
|
|
16 |
|
|
17 |
static bool str_compare(const char* a_, const char* b_)
|
|
18 |
{
|
|
19 |
return strcmp(a_, b_) < 0 ? 1 : 0;
|
|
20 |
}
|
|
21 |
|
|
22 |
int maxelem2_test(int, char**)
|
|
23 |
{
|
|
24 |
cout<<"Results of maxelem2_test:"<<endl;
|
|
25 |
|
|
26 |
char* names[] = { "Brett", "Graham", "Jack", "Mike", "Todd" };
|
|
27 |
|
|
28 |
const unsigned namesCt = sizeof(names)/sizeof(names[0]);
|
|
29 |
string max1 = *max_element((char**)names, (char**)names + namesCt, str_compare);
|
|
30 |
cout << *max_element((char**)names, (char**)names + namesCt, str_compare) << endl;
|
|
31 |
if(max1 == "Todd")
|
|
32 |
return 0;
|
|
33 |
else
|
|
34 |
return 1;
|
|
35 |
}
|