summaryrefslogtreecommitdiff
path: root/boost/variant/variant.hpp
diff options
context:
space:
mode:
authorDongHun Kwak <dh0128.kwak@samsung.com>2016-03-21 15:45:20 +0900
committerDongHun Kwak <dh0128.kwak@samsung.com>2016-03-21 15:46:37 +0900
commit733b5d5ae2c5d625211e2985ac25728ac3f54883 (patch)
treea5b214744b256f07e1dc2bd7273035a7808c659f /boost/variant/variant.hpp
parent08c1e93fa36a49f49325a07fe91ff92c964c2b6c (diff)
downloadboost-733b5d5ae2c5d625211e2985ac25728ac3f54883.tar.gz
boost-733b5d5ae2c5d625211e2985ac25728ac3f54883.tar.bz2
boost-733b5d5ae2c5d625211e2985ac25728ac3f54883.zip
Imported Upstream version 1.58.0upstream/1.58.0
Change-Id: If0072143aa26874812e0db6872e1efb10a3e5e94 Signed-off-by: DongHun Kwak <dh0128.kwak@samsung.com>
Diffstat (limited to 'boost/variant/variant.hpp')
-rw-r--r--boost/variant/variant.hpp91
1 files changed, 89 insertions, 2 deletions
diff --git a/boost/variant/variant.hpp b/boost/variant/variant.hpp
index 02366be8ad..c4857edb26 100644
--- a/boost/variant/variant.hpp
+++ b/boost/variant/variant.hpp
@@ -4,7 +4,7 @@
//-----------------------------------------------------------------------------
//
// Copyright (c) 2002-2003 Eric Friedman, Itay Maman
-// Copyright (c) 2012-2013 Antony Polukhin
+// Copyright (c) 2012-2014 Antony Polukhin
//
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
@@ -48,6 +48,7 @@
#include "boost/type_traits/add_const.hpp"
#include "boost/type_traits/has_nothrow_constructor.hpp"
#include "boost/type_traits/has_nothrow_copy.hpp"
+#include "boost/type_traits/is_nothrow_move_assignable.hpp"
#include "boost/type_traits/is_nothrow_move_constructible.hpp"
#include "boost/type_traits/is_const.hpp"
#include "boost/type_traits/is_same.hpp"
@@ -681,8 +682,46 @@ private: // helpers, for visitor interface (below)
template <typename LhsT>
void backup_assign_impl(
+ backup_holder<LhsT>& lhs_content
+ , mpl::false_ // is_nothrow_move_constructible
+ , long
+ )
+ {
+ // Move lhs content to backup...
+ backup_holder<LhsT> backup_lhs_content(0);
+ backup_lhs_content.swap(lhs_content); // nothrow
+
+ // ...destroy lhs content...
+ lhs_content.~backup_holder<LhsT>(); // nothrow
+
+ BOOST_TRY
+ {
+ // ...and attempt to copy rhs content into lhs storage:
+ copy_rhs_content_(lhs_.storage_.address(), rhs_content_);
+ }
+ BOOST_CATCH (...)
+ {
+ // In case of failure, copy backup pointer to lhs storage...
+ new(lhs_.storage_.address())
+ backup_holder<LhsT>( 0 ); // nothrow
+
+ static_cast<backup_holder<LhsT>* >(lhs_.storage_.address())
+ ->swap(backup_lhs_content); // nothrow
+
+ // ...and rethrow:
+ BOOST_RETHROW;
+ }
+ BOOST_CATCH_END
+
+ // In case of success, indicate new content type:
+ lhs_.indicate_which(rhs_which_); // nothrow
+ }
+
+ template <typename LhsT>
+ void backup_assign_impl(
LhsT& lhs_content
, mpl::true_ // is_nothrow_move_constructible
+ , int
)
{
// Move lhs content to backup...
@@ -719,6 +758,7 @@ private: // helpers, for visitor interface (below)
void backup_assign_impl(
LhsT& lhs_content
, mpl::false_ // is_nothrow_move_constructible
+ , int
)
{
// Backup lhs content...
@@ -762,7 +802,7 @@ public: // visitor interface
typedef typename is_nothrow_move_constructible<LhsT>::type
nothrow_move;
- backup_assign_impl( lhs_content, nothrow_move() );
+ backup_assign_impl( lhs_content, nothrow_move(), 1L);
BOOST_VARIANT_AUX_RETURN_VOID;
}
@@ -2165,6 +2205,30 @@ public: // prevent comparison with foreign types
BOOST_STATIC_ASSERT( false && sizeof(U) );
}
+ template <typename U>
+ void operator!=(const U&) const
+ {
+ BOOST_STATIC_ASSERT( false && sizeof(U) );
+ }
+
+ template <typename U>
+ void operator>(const U&) const
+ {
+ BOOST_STATIC_ASSERT( false && sizeof(U) );
+ }
+
+ template <typename U>
+ void operator<=(const U&) const
+ {
+ BOOST_STATIC_ASSERT( false && sizeof(U) );
+ }
+
+ template <typename U>
+ void operator>=(const U&) const
+ {
+ BOOST_STATIC_ASSERT( false && sizeof(U) );
+ }
+
public: // comparison operators
// [MSVC6 requires these operators appear after template operators]
@@ -2195,6 +2259,28 @@ public: // comparison operators
return rhs.apply_visitor(visitor);
}
+ ///////////////////////////////////////////////////////////////////////////////
+ // comparison operators != > <= >=
+ inline bool operator!=(const variant& rhs) const
+ {
+ return !(*this == rhs);
+ }
+
+ inline bool operator>(const variant& rhs) const
+ {
+ return rhs < *this;
+ }
+
+ inline bool operator<=(const variant& rhs) const
+ {
+ return !(*this > rhs);
+ }
+
+ inline bool operator>=(const variant& rhs) const
+ {
+ return !(*this < rhs);
+ }
+
// helpers, for visitation support (below) -- private when possible
#if !defined(BOOST_NO_MEMBER_TEMPLATE_FRIENDS)
@@ -2303,6 +2389,7 @@ public: // metafunction result
};
+
///////////////////////////////////////////////////////////////////////////////
// function template swap
//