Adobe Source Libraries 1.49.0
A collection of C++ libraries.
Loading...
Searching...
No Matches
check_traversable.hpp
Go to the documentation of this file.
1/*
2 Copyright 2008 Adobe Systems Incorporated
3 Distributed under the Boost Software License - Version 1.0 (see the accompanying file LICENSE
4 or a copy at https://stlab.github.io/adobe_source_libraries/licenses.html)
5*/
6
7/**************************************************************************************************/
8
9#include <adobe/config.hpp>
10
11#include <boost/concept_check.hpp>
12
13#include <adobe/implementation/swap.hpp>
15#include <iostream>
16
17namespace adobe {
21template <typename T>
22void check_traversable(const T& c) {
23
24 // http://www.sgi.com/tech/stl/Container.html
25
26 boost::function_requires<boost::ContainerConcept<T>>();
28 {
29 // some valid expressions
30 const T d1(c);
31 T d2(c);
32 typename T::const_iterator i1 = d1.begin(), i2 = d1.end(), i3 = d2.begin(), i4 = d2.end();
33 (void)i1;
34 (void)i2;
35 (void)i3;
36 (void)i4;
37 typename T::iterator j1 = d2.begin(), j2 = d2.end();
38 (void)j1;
39 (void)j2;
40 }
41
42
43 {
44 T d(c);
45 BOOST_CHECK_MESSAGE(c.size() == d.size(), "container copy-ctor size");
46 typename T::const_iterator i = c.begin(), j = d.begin();
47 (void)i;
48 (void)j;
49
50 BOOST_CHECK_MESSAGE(d == c, "container copy-ctor values");
51 }
52
53 {
54 T d;
55 d = c;
56 BOOST_CHECK_MESSAGE(c.size() == d.size(), "container assignment copy-ctor size");
57
58
59 BOOST_CHECK_MESSAGE(d == c, "container copy-ctor values");
60 }
61
62
63 {
64 T d;
65 BOOST_CHECK_MESSAGE(c.max_size() >= c.size() && 0 <= c.size(), "container maximum size");
66 BOOST_CHECK_MESSAGE(d.max_size() >= d.size() && 0 <= d.size(), "container maximum size");
67 BOOST_CHECK_MESSAGE(c.empty() == (c.size() == 0), "container empty");
68 BOOST_CHECK_MESSAGE(d.empty() == (d.size() == 0), "container empty");
69 }
70
71
72 {
73 using std::swap;
74 T d1(c);
75 T d2(c);
76 T d3;
77 T d4;
78
79 d1.swap(d3);
80 swap(d3, d4);
81 BOOST_CHECK_MESSAGE(d1 == d3 && d2 == d4, "container swap");
82 }
83
84 {
85 typename T::iterator x;
86 typename T::const_iterator y;
87
88 y = x; // Make sure mutable iterator can be converted to const.
89
90 (void)(y == x); // Make sure const/mutable iterators can be compared.
91 (void)(x == y);
92 }
93}
94
95#if 0
96//gcc always instantiates this
97BOOST_TEST_CASE_TEMPLATE_FUNCTION(check_traversables, T)
98{
99 check_traversable(arbitrary_traversable<T>());
100}
101#endif
102} // namespace adobe
BOOST_TEST_CASE_TEMPLATE_FUNCTION(check_regulars, T)
void check_traversable(const T &c)
void check_regular(const T &x)
void swap(any_regular_t &x, any_regular_t &y)
void swap(adobe::extents_t::slice_t &x, adobe::extents_t::slice_t &y) BOOST_NOEXCEPT
Definition extents.hpp:120