forked from boostorg/concept_check
new examples
[SVN r8066]
This commit is contained in:
@@ -330,6 +330,69 @@ at the top of the definition for <tt>std::vector</tt>.
|
|||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
|
|
||||||
|
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
|
||||||
|
<tt>REQUIRE</tt> macro with the type and concept in question. The
|
||||||
|
file <a href="./stl_concept_checks.cpp"><tt>stl_concept_checks.cpp</tt></a>
|
||||||
|
gives and example of applying the concept checks to STL
|
||||||
|
containers. The file is listed here:
|
||||||
|
|
||||||
|
<pre>
|
||||||
|
#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;
|
||||||
|
}
|
||||||
|
</pre>
|
||||||
|
|
||||||
|
|
||||||
<h2><a name="creating-concept-checks">Creating Concept Checking Classes</a></h2>
|
<h2><a name="creating-concept-checks">Creating Concept Checking Classes</a></h2>
|
||||||
|
|
||||||
As an example of how to create a concept checking class, we look
|
As an example of how to create a concept checking class, we look
|
||||||
|
Reference in New Issue
Block a user