]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/icl/include/boost/icl/concept/container.hpp
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / icl / include / boost / icl / concept / container.hpp
CommitLineData
7c673cae
FG
1/*-----------------------------------------------------------------------------+
2Copyright (c) 2010-2010: Joachim Faulhaber
3+------------------------------------------------------------------------------+
4 Distributed under the Boost Software License, Version 1.0.
5 (See accompanying file LICENCE.txt or copy at
6 http://www.boost.org/LICENSE_1_0.txt)
7+-----------------------------------------------------------------------------*/
8#ifndef BOOST_ICL_CONCEPT_CONTAINER_HPP_JOFA_100923
9#define BOOST_ICL_CONCEPT_CONTAINER_HPP_JOFA_100923
10
11#include <boost/utility/enable_if.hpp>
12#include <boost/mpl/and.hpp>
13#include <boost/mpl/not.hpp>
14#include <boost/icl/type_traits/is_container.hpp>
15#include <boost/icl/type_traits/is_icl_container.hpp>
16
17namespace boost{ namespace icl
18{
19
20//==============================================================================
21//= Emptieness
22//==============================================================================
23
24/** Tests if the container is empty.
25 Complexity: constant. */
26template<class Type>
27typename enable_if<is_container<Type>, bool>::type
28is_empty(const Type& object)
29{
30 return object.begin()==object.end();
31}
32
33
34/** All content of the container is dropped.
35 Complexity: linear. */
36template<class Type>
37typename enable_if<is_container<Type>, void>::type
38clear(Type& object)
39{
40 object.erase(object.begin(), object.end());
41}
42
43//==============================================================================
44//= Size
45//==============================================================================
46
47template<class Type>
48typename enable_if<mpl::and_< is_container<Type>
49 , mpl::not_<is_icl_container<Type> > >
50 , std::size_t>::type
51iterative_size(const Type& object)
52{
53 return object.size();
54}
55
56//==============================================================================
57//= Swap
58//==============================================================================
59
60template<class Type>
61typename enable_if<is_container<Type>, void>::type
62swap(Type& left, Type& right)
63{
64 left.swap(right);
65}
66
67//==============================================================================
68//= Iteration
69//==============================================================================
70
71template<class Type>
72typename enable_if<is_container<Type>, typename Type::iterator>::type
73cyclic_prior(Type& object, typename Type::iterator it_)
74{ return it_ == object.begin() ? object.end() : --it_; }
75
76template<class Type>
77typename enable_if<is_container<Type>, typename Type::const_iterator>::type
78cyclic_prior(const Type& object, typename Type::const_iterator it_)
79{ return it_ == object.begin() ? object.end() : --it_; }
80
81
82
83}} // namespace boost icl
84
85#endif
86
87