fix bug with defaulted move in msvc 12.0

This commit is contained in:
Andrzej Krzemienski
2017-10-31 01:26:18 +01:00
parent ebef3ed6f7
commit 58f7c2f14a
10 changed files with 58 additions and 14 deletions

View File

@ -35,7 +35,7 @@ We call it a ['direct] storage. This makes `optional<T>` a trivially-copyable ty
[heading Controlling the size]
For the purpose of the followin analysis, considering memory layouts, we can think of it as:
For the purpose of the following analysis, considering memory layouts, we can think of it as:
template <typename T>
class optional

View File

@ -82,7 +82,7 @@
the size</a>
</h5>
<p>
For the purpose of the followin analysis, considering memory layouts, we
For the purpose of the following analysis, considering memory layouts, we
can think of it as:
</p>
<pre class="programlisting"><span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">typename</span> <span class="identifier">T</span><span class="special">&gt;</span>

View File

@ -146,7 +146,7 @@
</div>
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"><p><small>Last revised: October 28, 2017 at 14:38:14 GMT</small></p></td>
<td align="left"><p><small>Last revised: October 30, 2017 at 22:34:46 GMT</small></p></td>
<td align="right"><div class="copyright-footer"></div></td>
</tr></table>
<hr>

View File

@ -113,4 +113,15 @@
# define BOOST_OPTIONAL_DETAIL_NO_SFINAE_FRIENDLY_CONSTRUCTORS
#endif
// Detection of correctly implemented defaulted functions
#ifdef BOOST_NO_CXX11_DEFAULTED_FUNCTIONS
# define BOOST_OPTIONAL_DETAIL_NO_DEFAULTED_FUNCTIONS
#elif BOOST_WORKAROUND(BOOST_MSVC, < 1900)
// on MSVC 12.0 move constructor and move assignment are not reconized as special functions
// and they cannot be defaulted
# define BOOST_OPTIONAL_DETAIL_NO_DEFAULTED_FUNCTIONS
#endif
#endif // header guard

View File

@ -954,7 +954,7 @@ class optional
// Creates a deep copy of another optional<T>
// Can throw if T::T(T const&) does
#ifndef BOOST_NO_CXX11_DEFAULTED_FUNCTIONS
#ifndef BOOST_OPTIONAL_DETAIL_NO_DEFAULTED_FUNCTIONS
optional ( optional const& ) = default;
#else
optional ( optional const& rhs ) : base( static_cast<base const&>(rhs) ) {}
@ -964,7 +964,7 @@ class optional
// Creates a deep move of another optional<T>
// Can throw if T::T(T&&) does
#ifndef BOOST_NO_CXX11_DEFAULTED_FUNCTIONS
#ifndef BOOST_OPTIONAL_DETAIL_NO_DEFAULTED_FUNCTIONS
optional ( optional && rhs ) = default;
#else
optional ( optional && rhs )
@ -1029,7 +1029,7 @@ class optional
// Assigns from another optional<T> (deep-copies the rhs value)
// Basic Guarantee: If T::T( T const& ) throws, this is left UNINITIALIZED
// (NOTE: On BCB, this operator is not actually called and left is left UNMODIFIED in case of a throw)
#ifndef BOOST_NO_CXX11_DEFAULTED_FUNCTIONS
#ifndef BOOST_OPTIONAL_DETAIL_NO_DEFAULTED_FUNCTIONS
optional& operator= ( optional const& rhs ) = default;
#else
optional& operator= ( optional const& rhs )
@ -1041,7 +1041,7 @@ class optional
#ifndef BOOST_OPTIONAL_DETAIL_NO_RVALUE_REFERENCES
// Assigns from another optional<T> (deep-moves the rhs value)
#ifndef BOOST_NO_CXX11_DEFAULTED_FUNCTIONS
#ifndef BOOST_OPTIONAL_DETAIL_NO_DEFAULTED_FUNCTIONS
optional& operator= ( optional && ) = default;
#else
optional& operator= ( optional && rhs )

View File

@ -67,12 +67,14 @@ import testing ;
[ compile-fail optional_test_fail_none_io_without_io.cpp ]
[ compile-fail optional_test_fail_convert_assign_of_enums.cpp ]
[ run optional_test_static_properties.cpp ]
[ compile optional_test_maybe_uninitialized_warning.cpp ]
[ compile optional_test_deleted_default_ctor.cpp ]
[ run optional_xconfig_NO_PROPER_ASSIGN_FROM_CONST_INT_pass.cpp ]
[ run-fail optional_xconfig_NO_PROPER_ASSIGN_FROM_CONST_INT_fail.cpp ]
[ run optional_xconfig_NO_PROPER_CONVERT_FROM_CONST_INT_pass.cpp ]
[ run-fail optional_xconfig_NO_PROPER_CONVERT_FROM_CONST_INT_fail.cpp ]
[ run optional_xconfig_NO_LEGAL_CONVERT_FROM_REF_pass.cpp ]
[ compile-fail optional_xconfig_NO_LEGAL_CONVERT_FROM_REF_fail.cpp ]
[ compile optional_test_deleted_default_ctor.cpp ]
;
}

View File

@ -21,7 +21,6 @@
#include "boost/core/lightweight_test.hpp"
using boost::optional;
using boost::make_optional;
template<class Opt>
void test2( Opt o, Opt buff )
@ -42,10 +41,10 @@ void test2( Opt o, Opt buff )
template<class T>
void test( T v, T w )
{
test2( make_optional(v), optional<T> ());
test2( make_optional(v), make_optional(w));
test2( boost::make_optional(v), optional<T> ());
test2( boost::make_optional(v), boost::make_optional(w));
test2( optional<T> () , optional<T> ());
test2( optional<T> () , make_optional(w));
test2( optional<T> () , boost::make_optional(w));
}

View File

@ -0,0 +1,32 @@
// Copyright (C) 2017 Andrzej Krzemienski.
//
// Use, modification, and distribution is subject to 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)
//
// See http://www.boost.org/lib/optional for documentation.
//
// You are welcome to contact the author at:
// akrzemi1@gmail.com
#include "boost/optional/optional.hpp"
#ifdef __BORLANDC__
#pragma hdrstop
#endif
boost::optional<int> getitem();
int main(int argc, const char *[])
{
boost::optional<int> a = getitem();
boost::optional<int> b;
if (argc > 0)
b = argc;
if (a != b)
return 1;
return 0;
}