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 namespace boost {
25 namespace intrusive {
26 namespace detail {
27 
28 template<bool ConstantSize, class SizeType, class Tag = void>
29 struct size_holder
30 {
31    static const bool constant_time_size = ConstantSize;
32    typedef SizeType  size_type;
33 
get_sizeboost::intrusive::detail::size_holder34    SizeType get_size() const
35    {  return size_;  }
36 
set_sizeboost::intrusive::detail::size_holder37    void set_size(SizeType size)
38    {  size_ = size; }
39 
decrementboost::intrusive::detail::size_holder40    void decrement()
41    {  --size_; }
42 
incrementboost::intrusive::detail::size_holder43    void increment()
44    {  ++size_; }
45 
increaseboost::intrusive::detail::size_holder46    void increase(SizeType n)
47    {  size_ += n; }
48 
decreaseboost::intrusive::detail::size_holder49    void decrease(SizeType n)
50    {  size_ -= n; }
51 
52    SizeType size_;
53 };
54 
55 template<class SizeType, class Tag>
56 struct size_holder<false, SizeType, Tag>
57 {
58    static const bool constant_time_size = false;
59    typedef SizeType  size_type;
60 
get_sizeboost::intrusive::detail::size_holder61    size_type get_size() const
62    {  return 0;  }
63 
set_sizeboost::intrusive::detail::size_holder64    void set_size(size_type)
65    {}
66 
decrementboost::intrusive::detail::size_holder67    void decrement()
68    {}
69 
incrementboost::intrusive::detail::size_holder70    void increment()
71    {}
72 
increaseboost::intrusive::detail::size_holder73    void increase(SizeType)
74    {}
75 
decreaseboost::intrusive::detail::size_holder76    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