Allocator Builder
Policy Based C++ Template Allocator Library
 All Classes Functions Variables Enumerations Enumerator Groups Pages
dynastic.hpp
1 //
3 // Copyright 2014 Felix Petriconi
4 //
5 // License: http://boost.org/LICENSE_1_0.txt, Boost License 1.0
6 //
7 // Authors: http://petriconi.net, Felix Petriconi
8 //
10 #pragma once
11 
12 #include <limits>
13 
14 namespace alb {
15  inline namespace v_100 {
16  namespace internal {
17 
23  enum DynasticOptions : size_t {
24  DynasticUndefined = std::numeric_limits<size_t>::max(),
25  DynasticDynamicSet = std::numeric_limits<size_t>::max() - 1
26  };
27 
36  template <size_t v, size_t DynamicEnableSwitch> struct dynastic {
37  size_t value() const noexcept
38  {
39  return v;
40  }
41  };
42 
43  template <size_t DynamicEnableSwitch>
44  struct dynastic<DynamicEnableSwitch, DynamicEnableSwitch> {
45  private:
46  size_t _v;
47 
48  public:
49  dynastic() noexcept
50  : _v(DynasticUndefined)
51  {
52  }
53 
54  size_t value() const noexcept
55  {
56  return _v;
57  }
58 
59  void value(size_t w) noexcept
60  {
61  _v = w;
62  }
63  };
64 
65  } // namespace internal
66  }
67 
68  using namespace v_100;
69 } // alb