]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/intrusive/include/boost/intrusive/detail/size_holder.hpp
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / libs / intrusive / include / boost / intrusive / detail / size_holder.hpp
1 /////////////////////////////////////////////////////////////////////////////
2 //
3 // (C) Copyright Ion Gaztanaga 2014-2014
4 //
5 // Distributed under the Boost Software License, Version 1.0.
6 // (See accompanying file LICENSE_1_0.txt or copy at
7 // http://www.boost.org/LICENSE_1_0.txt)
8 //
9 // See http://www.boost.org/libs/intrusive for documentation.
10 //
11 /////////////////////////////////////////////////////////////////////////////
12
13 #ifndef BOOST_INTRUSIVE_DETAIL_SIZE_HOLDER_HPP
14 #define BOOST_INTRUSIVE_DETAIL_SIZE_HOLDER_HPP
15
16 #ifndef BOOST_CONFIG_HPP
17 # include <boost/config.hpp>
18 #endif
19
20 #if defined(BOOST_HAS_PRAGMA_ONCE)
21 # pragma once
22 #endif
23
24 #include <boost/intrusive/detail/workaround.hpp>
25
26 namespace boost {
27 namespace intrusive {
28 namespace detail {
29
30 template<bool ConstantSize, class SizeType, class Tag = void>
31 struct size_holder
32 {
33 static const bool constant_time_size = ConstantSize;
34 typedef SizeType size_type;
35
36 BOOST_INTRUSIVE_FORCEINLINE SizeType get_size() const
37 { return size_; }
38
39 BOOST_INTRUSIVE_FORCEINLINE void set_size(SizeType size)
40 { size_ = size; }
41
42 BOOST_INTRUSIVE_FORCEINLINE void decrement()
43 { --size_; }
44
45 BOOST_INTRUSIVE_FORCEINLINE void increment()
46 { ++size_; }
47
48 BOOST_INTRUSIVE_FORCEINLINE void increase(SizeType n)
49 { size_ += n; }
50
51 BOOST_INTRUSIVE_FORCEINLINE void decrease(SizeType n)
52 { size_ -= n; }
53
54 BOOST_INTRUSIVE_FORCEINLINE void swap(size_holder &other)
55 { SizeType tmp(size_); size_ = other.size_; other.size_ = tmp; }
56
57 SizeType size_;
58 };
59
60 template<class SizeType, class Tag>
61 struct size_holder<false, SizeType, Tag>
62 {
63 static const bool constant_time_size = false;
64 typedef SizeType size_type;
65
66 BOOST_INTRUSIVE_FORCEINLINE size_type get_size() const
67 { return 0; }
68
69 BOOST_INTRUSIVE_FORCEINLINE void set_size(size_type)
70 {}
71
72 BOOST_INTRUSIVE_FORCEINLINE void decrement()
73 {}
74
75 BOOST_INTRUSIVE_FORCEINLINE void increment()
76 {}
77
78 BOOST_INTRUSIVE_FORCEINLINE void increase(SizeType)
79 {}
80
81 BOOST_INTRUSIVE_FORCEINLINE void decrease(SizeType)
82 {}
83
84 BOOST_INTRUSIVE_FORCEINLINE void swap(size_holder){}
85 };
86
87 } //namespace detail{
88 } //namespace intrusive{
89 } //namespace boost{
90
91 #endif //BOOST_INTRUSIVE_DETAIL_SIZE_HOLDER_HPP