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 lwrbnd2_test main
|
|
11 |
#endif
|
|
12 |
|
|
13 |
#if !defined (STLPORT) || defined(__STL_USE_NAMESPACES)
|
|
14 |
using namespace std;
|
|
15 |
#endif
|
|
16 |
static bool char_str_less(const char* a_, const char* b_)
|
|
17 |
{
|
|
18 |
return strcmp(a_, b_) < 0 ? 1 : 0;
|
|
19 |
}
|
|
20 |
|
|
21 |
int lwrbnd2_test(int, char**)
|
|
22 |
{
|
|
23 |
cout<<"Results of lwrbnd2_test:"<<endl;
|
|
24 |
|
|
25 |
char* str [] = { "a", "a", "b", "b", "q", "w", "z" };
|
|
26 |
|
|
27 |
const unsigned strCt = sizeof(str)/sizeof(str[0]);
|
|
28 |
// DEC C++ generates incorrect template instatiation code
|
|
29 |
// for "d" so must cast
|
|
30 |
cout
|
|
31 |
<< "d can be inserted at index: "
|
|
32 |
<<(lower_bound((char**)str, (char**)str + strCt, (const char *)"d", char_str_less) - str)
|
|
33 |
<< endl;
|
|
34 |
if((lower_bound((char**)str, (char**)str + strCt, (const char *)"d", char_str_less) - str) == 4)
|
|
35 |
return 0;
|
|
36 |
else
|
|
37 |
return 1;
|
|
38 |
}
|