source: trunk/config.tests/unix/stl/stltest.cpp@ 106

Last change on this file since 106 was 2, checked in by Dmitry A. Kuminov, 16 years ago

Initially imported qt-all-opensource-src-4.5.1 from Trolltech.

File size: 1.8 KB
Line 
1/* Sample program for configure to test STL support on target
2platforms. We are mainly concerned with being able to instantiate
3templates for common STL container classes.
4*/
5
6#include <iterator>
7#include <map>
8#include <vector>
9#include <algorithm>
10#include <iostream>
11
12int main()
13{
14 std::vector<int> v1;
15 v1.push_back( 0 );
16 v1.push_back( 1 );
17 v1.push_back( 2 );
18 v1.push_back( 3 );
19 v1.push_back( 4 );
20 int v1size = v1.size();
21 v1size = 0;
22 int v1capacity = v1.capacity();
23 v1capacity = 0;
24
25 std::vector<int>::iterator v1it = std::find( v1.begin(), v1.end(), 99 );
26 bool v1notfound = (v1it == v1.end());
27 v1notfound = false;
28
29 v1it = std::find( v1.begin(), v1.end(), 3 );
30 bool v1found = (v1it != v1.end());
31 v1found = false;
32
33 std::vector<int> v2;
34 std::copy( v1.begin(), v1it, std::back_inserter( v2 ) );
35 int v2size = v2.size();
36 v2size = 0;
37
38 std::map<int, double> m1;
39 m1.insert( std::make_pair( 1, 2.0 ) );
40 m1.insert( std::make_pair( 3, 2.0 ) );
41 m1.insert( std::make_pair( 5, 2.0 ) );
42 m1.insert( std::make_pair( 7, 2.0 ) );
43 int m1size = m1.size();
44 m1size = 0;
45 std::map<int,double>::iterator m1it = m1.begin();
46 for ( ; m1it != m1.end(); ++m1it ) {
47 int first = (*m1it).first;
48 first = 0;
49 double second = (*m1it).second;
50 second = 0.0;
51 }
52 std::map< int, double > m2( m1 );
53 int m2size = m2.size();
54 m2size = 0;
55
56 return 0;
57}
58
59// something mean to see if the compiler and C++ standard lib are good enough
60template<class K, class T>
61class DummyClass
62{
63 // everything in std namespace ?
64 typedef std::bidirectional_iterator_tag i;
65 typedef std::ptrdiff_t d;
66 // typename implemented ?
67 typedef typename std::map<K,T>::iterator MyIterator;
68};
Note: See TracBrowser for help on using the repository browser.