Mercurial > hg > vamp-build-and-test
diff DEPENDENCIES/generic/include/boost/variant/detail/backup_holder.hpp @ 16:2665513ce2d3
Add boost headers
author | Chris Cannam |
---|---|
date | Tue, 05 Aug 2014 11:11:38 +0100 |
parents | |
children | c530137014c0 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/DEPENDENCIES/generic/include/boost/variant/detail/backup_holder.hpp Tue Aug 05 11:11:38 2014 +0100 @@ -0,0 +1,95 @@ +//----------------------------------------------------------------------------- +// 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/config.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) BOOST_NOEXCEPT + : 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) BOOST_NOEXCEPT + { + 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) BOOST_NOEXCEPT +{ + lhs.swap(rhs); +} + +}} // namespace detail::variant +} // namespace boost + +#endif // BOOST_VARIANT_DETAIL_BACKUP_HOLDER_HPP