diff options
author | Remko Tronçon <git@el-tramo.be> | 2010-08-08 18:41:53 (GMT) |
---|---|---|
committer | Remko Tronçon <git@el-tramo.be> | 2010-08-08 18:41:53 (GMT) |
commit | 19df82042f44c201e5a2821b4fa35465e33a1c90 (patch) | |
tree | 1746bddfa31ce2a6488ef5186036a049a255c9da /3rdParty/Boost/src/boost/variant/detail/backup_holder.hpp | |
parent | 4a5a0977f661bf5c7c34ee7aa48b35073a682203 (diff) | |
download | swift-contrib-19df82042f44c201e5a2821b4fa35465e33a1c90.zip swift-contrib-19df82042f44c201e5a2821b4fa35465e33a1c90.tar.bz2 |
Added XEP-0004 data forms parsing & serializing.
Diffstat (limited to '3rdParty/Boost/src/boost/variant/detail/backup_holder.hpp')
-rw-r--r-- | 3rdParty/Boost/src/boost/variant/detail/backup_holder.hpp | 94 |
1 files changed, 94 insertions, 0 deletions
diff --git a/3rdParty/Boost/src/boost/variant/detail/backup_holder.hpp b/3rdParty/Boost/src/boost/variant/detail/backup_holder.hpp new file mode 100644 index 0000000..ed112b8 --- /dev/null +++ b/3rdParty/Boost/src/boost/variant/detail/backup_holder.hpp @@ -0,0 +1,94 @@ +//----------------------------------------------------------------------------- +// boost variant/detail/backup_holder.hpp header file +// See http://www.boost.org for updates, documentation, and revision history. +//----------------------------------------------------------------------------- +// +// Copyright (c) 2003 +// Eric Friedman +// +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_VARIANT_DETAIL_BACKUP_HOLDER_HPP +#define BOOST_VARIANT_DETAIL_BACKUP_HOLDER_HPP + +#include "boost/assert.hpp" + +namespace boost { +namespace detail { namespace variant { + +template <typename T> +class backup_holder +{ +private: // representation + + T* backup_; + +public: // structors + + ~backup_holder() + { + delete backup_; + } + + explicit backup_holder(T* backup) + : backup_(backup) + { + } + + backup_holder(const backup_holder&); + +public: // modifiers + + backup_holder& operator=(const backup_holder& rhs) + { + *backup_ = rhs.get(); + return *this; + } + + backup_holder& operator=(const T& rhs) + { + *backup_ = rhs; + return *this; + } + + void swap(backup_holder& rhs) + { + T* tmp = rhs.backup_; + rhs.backup_ = this->backup_; + this->backup_ = tmp; + } + +public: // queries + + T& get() + { + return *backup_; + } + + const T& get() const + { + return *backup_; + } + +}; + +template <typename T> +backup_holder<T>::backup_holder(const backup_holder&) + : backup_(0) +{ + // not intended for copy, but do not want to prohibit syntactically + BOOST_ASSERT(false); +} + +template <typename T> +void swap(backup_holder<T>& lhs, backup_holder<T>& rhs) +{ + lhs.swap(rhs); +} + +}} // namespace detail::variant +} // namespace boost + +#endif // BOOST_VARIANT_DETAIL_BACKUP_HOLDER_HPP |