]> git.proxmox.com Git - ceph.git/blame - ceph/src/Beast/extras/beast/unit_test/detail/const_container.hpp
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / Beast / extras / beast / unit_test / detail / const_container.hpp
CommitLineData
7c673cae
FG
1//
2// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com)
3//
4// Distributed under the Boost Software License, Version 1.0. (See accompanying
5// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6//
7
8#ifndef BEAST_UNIT_TEST_DETAIL_CONST_CONTAINER_HPP
9#define BEAST_UNIT_TEST_DETAIL_CONST_CONTAINER_HPP
10
11namespace beast {
12namespace unit_test {
13namespace detail {
14
15/** Adapter to constrain a container interface.
16 The interface allows for limited read only operations. Derived classes
17 provide additional behavior.
18*/
19template<class Container>
20class const_container
21{
22private:
23 using cont_type = Container;
24
25 cont_type m_cont;
26
27protected:
28 cont_type& cont()
29 {
30 return m_cont;
31 }
32
33 cont_type const& cont() const
34 {
35 return m_cont;
36 }
37
38public:
39 using value_type = typename cont_type::value_type;
40 using size_type = typename cont_type::size_type;
41 using difference_type = typename cont_type::difference_type;
42 using iterator = typename cont_type::const_iterator;
43 using const_iterator = typename cont_type::const_iterator;
44
45 /** Returns `true` if the container is empty. */
46 bool
47 empty() const
48 {
49 return m_cont.empty();
50 }
51
52 /** Returns the number of items in the container. */
53 size_type
54 size() const
55 {
56 return m_cont.size();
57 }
58
59 /** Returns forward iterators for traversal. */
60 /** @{ */
61 const_iterator
62 begin() const
63 {
64 return m_cont.cbegin();
65 }
66
67 const_iterator
68 cbegin() const
69 {
70 return m_cont.cbegin();
71 }
72
73 const_iterator
74 end() const
75 {
76 return m_cont.cend();
77 }
78
79 const_iterator
80 cend() const
81 {
82 return m_cont.cend();
83 }
84 /** @} */
85};
86
87} // detail
88} // unit_test
89} // beast
90
91#endif