File: stl_concept_check.cpp

package info (click to toggle)
boost 1.27.0-3
  • links: PTS
  • area: main
  • in suites: woody
  • size: 19,908 kB
  • ctags: 26,546
  • sloc: cpp: 122,225; ansic: 10,956; python: 4,412; sh: 855; yacc: 803; makefile: 257; perl: 165; lex: 90; csh: 6
file content (93 lines) | stat: -rw-r--r-- 3,361 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
// (C) Copyright Jeremy Siek 2000. Permission to copy, use, modify,
// sell and distribute this software is granted provided this
// copyright notice appears in all copies. This software is provided
// "as is" without express or implied warranty, and with no claim as
// to its suitability for any purpose.

//
// This file checks to see if various standard container
// implementations live up to requirements specified in the C++
// standard. As many implementations do not live to the requirements,
// it is not uncommon for this file to fail to compile. The
// BOOST_HIDE_EXPECTED_ERRORS macro is provided here if you want to
// see as much of this file compile as possible.
//

#include <boost/concept_check.hpp>

#include <iterator>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <deque>
#ifndef BOOST_NO_SLIST
#include <slist>
#endif

// Define this macro if you want to hide the expected error, that is,
// error in the various C++ standard library implementations.
//
//#define BOOST_HIDE_EXPECTED_ERRORS

int
main()
{
  using namespace boost;

#if defined(_ITERATOR_) && defined(BOOST_HIDE_EXPECTED_ERRORS)
  // VC++ STL implementation is not standard conformant and
  // fails to pass these concept checks
#else
  typedef std::vector<int> Vector;
  typedef std::deque<int> Deque;
  typedef std::list<int> List;

  // VC++ missing pointer and const_pointer typedefs
  function_requires< Mutable_RandomAccessContainerConcept<Vector> >();
  function_requires< BackInsertionSequenceConcept<Vector> >();

#if !(defined(__GNUC__) && defined(BOOST_HIDE_EXPECTED_ERRORS))
#if !(defined(__sgi) && defined(BOOST_HIDE_EXPECTED_ERRORS))
  // old deque iterator missing n + iter operation
  function_requires< Mutable_RandomAccessContainerConcept<Deque> >();
#endif
  // warnings about signed and unsigned in old deque version
  function_requires< FrontInsertionSequenceConcept<Deque> >();
  function_requires< BackInsertionSequenceConcept<Deque> >();
#endif

  // VC++ missing pointer and const_pointer typedefs
  function_requires< Mutable_ReversibleContainerConcept<List> >();
  function_requires< FrontInsertionSequenceConcept<List> >();
  function_requires< BackInsertionSequenceConcept<List> >();

#ifndef BOOST_NO_SLIST
  typedef BOOST_STD_EXTENSION_NAMESPACE::slist<int> SList;
  function_requires< FrontInsertionSequenceConcept<SList> >();
#endif

  typedef std::set<int> Set;
  typedef std::multiset<int> MultiSet;
  typedef std::map<int,int> Map;
  typedef std::multimap<int,int> MultiMap;

  function_requires< SortedAssociativeContainerConcept<Set> >();
  function_requires< SimpleAssociativeContainerConcept<Set> >();
  function_requires< UniqueAssociativeContainerConcept<Set> >();

  function_requires< SortedAssociativeContainerConcept<MultiSet> >();
  function_requires< SimpleAssociativeContainerConcept<MultiSet> >();
  function_requires< MultipleAssociativeContainerConcept<MultiSet> >();

  function_requires< SortedAssociativeContainerConcept<Map> >();
  function_requires< UniqueAssociativeContainerConcept<Map> >();
  function_requires< PairAssociativeContainerConcept<Map> >();

  function_requires< SortedAssociativeContainerConcept<MultiMap> >();
  function_requires< MultipleAssociativeContainerConcept<MultiMap> >();
  function_requires< PairAssociativeContainerConcept<MultiMap> >();
#endif

  return 0;
}