]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/boost/variant/detail/backup_holder.hpp
update sources to v12.2.3
[ceph.git] / ceph / src / boost / boost / variant / detail / backup_holder.hpp
1 //-----------------------------------------------------------------------------
2 // boost variant/detail/backup_holder.hpp header file
3 // See http://www.boost.org for updates, documentation, and revision history.
4 //-----------------------------------------------------------------------------
5 //
6 // Copyright (c) 2003
7 // Eric Friedman
8 //
9 // Distributed under the Boost Software License, Version 1.0. (See
10 // accompanying file LICENSE_1_0.txt or copy at
11 // http://www.boost.org/LICENSE_1_0.txt)
12
13 #ifndef BOOST_VARIANT_DETAIL_BACKUP_HOLDER_HPP
14 #define BOOST_VARIANT_DETAIL_BACKUP_HOLDER_HPP
15
16 #include <boost/config.hpp>
17 #include <boost/assert.hpp>
18
19 namespace boost {
20 namespace detail { namespace variant {
21
22 template <typename T>
23 class backup_holder
24 {
25 private: // representation
26
27 T* backup_;
28
29 public: // structors
30
31 ~backup_holder() BOOST_NOEXCEPT
32 {
33 delete backup_;
34 }
35
36 explicit backup_holder(T* backup) BOOST_NOEXCEPT
37 : backup_(backup)
38 {
39 }
40
41 backup_holder(const backup_holder&);
42
43 public: // modifiers
44
45 backup_holder& operator=(const backup_holder& rhs)
46 {
47 *backup_ = rhs.get();
48 return *this;
49 }
50
51 backup_holder& operator=(const T& rhs)
52 {
53 *backup_ = rhs;
54 return *this;
55 }
56
57 void swap(backup_holder& rhs) BOOST_NOEXCEPT
58 {
59 T* tmp = rhs.backup_;
60 rhs.backup_ = this->backup_;
61 this->backup_ = tmp;
62 }
63
64 public: // queries
65
66 T& get() BOOST_NOEXCEPT
67 {
68 return *backup_;
69 }
70
71 const T& get() const BOOST_NOEXCEPT
72 {
73 return *backup_;
74 }
75
76 };
77
78 template <typename T>
79 backup_holder<T>::backup_holder(const backup_holder&)
80 : backup_(0)
81 {
82 // not intended for copy, but do not want to prohibit syntactically
83 BOOST_ASSERT(false);
84 }
85
86 template <typename T>
87 void swap(backup_holder<T>& lhs, backup_holder<T>& rhs) BOOST_NOEXCEPT
88 {
89 lhs.swap(rhs);
90 }
91
92 }} // namespace detail::variant
93 } // namespace boost
94
95 #endif // BOOST_VARIANT_DETAIL_BACKUP_HOLDER_HPP