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
24namespace boost {
25namespace intrusive {
26namespace detail {
27
28template<bool ConstantSize, class SizeType, class Tag = void>
29struct size_holder
30{
31 static const bool constant_time_size = ConstantSize;
32 typedef SizeType size_type;
33
34 SizeType get_size() const
35 { return size_; }
36
37 void set_size(SizeType size)
38 { size_ = size; }
39
40 void decrement()
41 { --size_; }
42
43 void increment()
44 { ++size_; }
45
46 void increase(SizeType n)
47 { size_ += n; }
48
49 void decrease(SizeType n)
50 { size_ -= n; }
51
52 SizeType size_;
53};
54
55template<class SizeType, class Tag>
56struct size_holder<false, SizeType, Tag>
57{
58 static const bool constant_time_size = false;
59 typedef SizeType size_type;
60
61 size_type get_size() const
62 { return 0; }
63
64 void set_size(size_type)
65 {}
66
67 void decrement()
68 {}
69
70 void increment()
71 {}
72
73 void increase(SizeType)
74 {}
75
76 void decrease(SizeType)
77 {}
78};
79
80} //namespace detail{
81} //namespace intrusive{
82} //namespace boost{
83
84#endif //BOOST_INTRUSIVE_DETAIL_SIZE_HOLDER_HPP
85