diff --git a/doc/1A_on_performance.qbk b/doc/1A_on_performance.qbk index 6459ffe..6bb68ce 100644 --- a/doc/1A_on_performance.qbk +++ b/doc/1A_on_performance.qbk @@ -35,7 +35,7 @@ We call it a ['direct] storage. This makes `optional` 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 class optional diff --git a/doc/html/boost_optional/tutorial/performance_considerations.html b/doc/html/boost_optional/tutorial/performance_considerations.html index 2c796da..40b4713 100644 --- a/doc/html/boost_optional/tutorial/performance_considerations.html +++ b/doc/html/boost_optional/tutorial/performance_considerations.html @@ -82,7 +82,7 @@ the size

- 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:

template <typename T>
diff --git a/doc/html/index.html b/doc/html/index.html
index de3b006..04c4c88 100644
--- a/doc/html/index.html
+++ b/doc/html/index.html
@@ -146,7 +146,7 @@
 
 
 
-
+

Last revised: October 28, 2017 at 14:38:14 GMT

Last revised: October 30, 2017 at 22:34:46 GMT


diff --git a/include/boost/optional/detail/optional_config.hpp b/include/boost/optional/detail/optional_config.hpp index deabd21..d5d3514 100644 --- a/include/boost/optional/detail/optional_config.hpp +++ b/include/boost/optional/detail/optional_config.hpp @@ -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 diff --git a/include/boost/optional/detail/optional_trivially_copyable_base.hpp b/include/boost/optional/detail/optional_trivially_copyable_base.hpp index 1deaeab..91328ac 100644 --- a/include/boost/optional/detail/optional_trivially_copyable_base.hpp +++ b/include/boost/optional/detail/optional_trivially_copyable_base.hpp @@ -496,4 +496,4 @@ class tc_optional_base : public optional_tag bool m_initialized ; T m_storage ; -} ; \ No newline at end of file +} ; diff --git a/include/boost/optional/optional.hpp b/include/boost/optional/optional.hpp index 54fca4e..6d5a5a7 100644 --- a/include/boost/optional/optional.hpp +++ b/include/boost/optional/optional.hpp @@ -954,7 +954,7 @@ class optional // Creates a deep copy of another optional // 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(rhs) ) {} @@ -964,7 +964,7 @@ class optional // Creates a deep move of another optional // 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 (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 (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 ) diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index 638012d..4cac806 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -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 ] + ; } diff --git a/test/optional_test_io.cpp b/test/optional_test_io.cpp index 196363e..9dab619 100644 --- a/test/optional_test_io.cpp +++ b/test/optional_test_io.cpp @@ -21,7 +21,6 @@ #include "boost/core/lightweight_test.hpp" using boost::optional; -using boost::make_optional; template void test2( Opt o, Opt buff ) @@ -42,10 +41,10 @@ void test2( Opt o, Opt buff ) template void test( T v, T w ) { - test2( make_optional(v), optional ()); - test2( make_optional(v), make_optional(w)); + test2( boost::make_optional(v), optional ()); + test2( boost::make_optional(v), boost::make_optional(w)); test2( optional () , optional ()); - test2( optional () , make_optional(w)); + test2( optional () , boost::make_optional(w)); } diff --git a/test/optional_test_maybe_uninitialized_warning.cpp b/test/optional_test_maybe_uninitialized_warning.cpp new file mode 100644 index 0000000..084834d --- /dev/null +++ b/test/optional_test_maybe_uninitialized_warning.cpp @@ -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 getitem(); + +int main(int argc, const char *[]) +{ + boost::optional a = getitem(); + boost::optional b; + + if (argc > 0) + b = argc; + + if (a != b) + return 1; + + return 0; +} \ No newline at end of file diff --git a/test/optional_test_static_properties.cpp b/test/optional_test_static_properties.cpp index 02695c7..02c1af6 100644 --- a/test/optional_test_static_properties.cpp +++ b/test/optional_test_static_properties.cpp @@ -137,4 +137,4 @@ int main() test_trivial_copyability(); #endif return boost::report_errors(); -} \ No newline at end of file +}