From 0fb40bbafae2b8dfa1805a60f13b6b049896d7bf Mon Sep 17 00:00:00 2001 From: Jeremy Siek Date: Sun, 29 Oct 2000 22:03:21 +0000 Subject: [PATCH] new examples [SVN r8066] --- concept_checking.html | 63 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) diff --git a/concept_checking.html b/concept_checking.html index 82451a9..10583f1 100644 --- a/concept_checking.html +++ b/concept_checking.html @@ -330,6 +330,69 @@ at the top of the definition for std::vector. +Although the concept checks are designed for use by generic library +implementors, they can also be useful to end users. Sometimes one may +not be sure whether some type models a particular concept. This can +easily be checked by creating a small program and using the +REQUIRE macro with the type and concept in question. The +file stl_concept_checks.cpp +gives and example of applying the concept checks to STL +containers. The file is listed here: + +
+  #include <boost/concept_checks.hpp>
+
+  #include <iterator>
+  #include <set>
+  #include <map>
+  #include <vector>
+  #include <list>
+  #include <deque>
+
+  int
+  main()
+  {
+    typedef std::vector<int> Vector;
+    typedef std::deque<int> Deque;
+    typedef std::list<int> List;
+
+    REQUIRE(Vector, Mutable_RandomAccessContainer);
+    REQUIRE(Vector, BackInsertionSequence);
+
+    REQUIRE(Deque, Mutable_RandomAccessContainer);
+    REQUIRE(Deque, FrontInsertionSequence);
+    REQUIRE(Deque, BackInsertionSequence);
+
+    REQUIRE(List, Mutable_ReversibleContainer);
+    REQUIRE(List, FrontInsertionSequence);
+    REQUIRE(List, BackInsertionSequence);
+
+    typedef std::set<int> Set;
+    typedef std::multiset<int> MultiSet;
+    typedef std::map<int,int> Map;
+    typedef std::multimap<int,int> MultiMap;
+
+    REQUIRE(Set, SortedAssociativeContainer);
+    REQUIRE(Set, SimpleAssociativeContainer);
+    REQUIRE(Set, UniqueAssociativeContainer);
+
+    REQUIRE(MultiSet, SortedAssociativeContainer);
+    REQUIRE(MultiSet, SimpleAssociativeContainer);
+    REQUIRE(MultiSet, MultipleAssociativeContainer);
+
+    REQUIRE(Map, SortedAssociativeContainer);
+    REQUIRE(Map, UniqueAssociativeContainer);
+    REQUIRE(Map, PairAssociativeContainer);
+
+    REQUIRE(MultiMap, SortedAssociativeContainer);
+    REQUIRE(MultiMap, MultipleAssociativeContainer);
+    REQUIRE(MultiMap, PairAssociativeContainer);
+
+    return 0;
+  }
+
+ +

Creating Concept Checking Classes

As an example of how to create a concept checking class, we look