Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-19 09:25:00

0001 //
0002 // Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com)
0003 //
0004 // Distributed under the Boost Software License, Version 1.0. (See accompanying
0005 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
0006 //
0007 // Official repository: https://github.com/boostorg/beast
0008 //
0009 
0010 #ifndef BOOST_BEAST_UNIT_TEST_DETAIL_CONST_CONTAINER_HPP
0011 #define BOOST_BEAST_UNIT_TEST_DETAIL_CONST_CONTAINER_HPP
0012 
0013 namespace boost {
0014 namespace beast {
0015 namespace unit_test {
0016 namespace detail {
0017 
0018 /** Adapter to constrain a container interface.
0019     The interface allows for limited read only operations. Derived classes
0020     provide additional behavior.
0021 */
0022 template<class Container>
0023 class const_container
0024 {
0025 private:
0026     using cont_type = Container;
0027 
0028     cont_type m_cont;
0029 
0030 protected:
0031     cont_type& cont()
0032     {
0033         return m_cont;
0034     }
0035 
0036     cont_type const& cont() const
0037     {
0038         return m_cont;
0039     }
0040 
0041 public:
0042     using value_type = typename cont_type::value_type;
0043     using size_type = typename cont_type::size_type;
0044     using difference_type = typename cont_type::difference_type;
0045     using iterator = typename cont_type::const_iterator;
0046     using const_iterator = typename cont_type::const_iterator;
0047 
0048     /** Returns `true` if the container is empty. */
0049     bool
0050     empty() const
0051     {
0052         return m_cont.empty();
0053     }
0054 
0055     /** Returns the number of items in the container. */
0056     size_type
0057     size() const
0058     {
0059         return m_cont.size();
0060     }
0061 
0062     /** Returns forward iterators for traversal. */
0063     /** @{ */
0064     const_iterator
0065     begin() const
0066     {
0067         return m_cont.cbegin();
0068     }
0069 
0070     const_iterator
0071     cbegin() const
0072     {
0073         return m_cont.cbegin();
0074     }
0075 
0076     const_iterator
0077     end() const
0078     {
0079         return m_cont.cend();
0080     }
0081 
0082     const_iterator
0083     cend() const
0084     {
0085         return m_cont.cend();
0086     }
0087     /** @} */
0088 };
0089 
0090 } // detail
0091 } // unit_test
0092 } // beast
0093 } // boost
0094 
0095 #endif