Fix trivially-constructible bug with deleted functions

This commit is contained in:
Andrzej Krzemienski
2017-11-02 22:46:09 +01:00
parent 01ebd2ad7f
commit 69bf75ae6d
2 changed files with 21 additions and 1 deletions

View File

@ -144,6 +144,16 @@
# define BOOST_OPTIONAL_DETAIL_NO_SPEC_FOR_TRIVIAL_TYPES # define BOOST_OPTIONAL_DETAIL_NO_SPEC_FOR_TRIVIAL_TYPES
#elif !defined BOOST_HAS_TRIVIAL_DESTRUCTOR #elif !defined BOOST_HAS_TRIVIAL_DESTRUCTOR
# define BOOST_OPTIONAL_DETAIL_NO_SPEC_FOR_TRIVIAL_TYPES # define BOOST_OPTIONAL_DETAIL_NO_SPEC_FOR_TRIVIAL_TYPES
#elif BOOST_WORKAROUND(BOOST_GCC, < 50000)
# define BOOST_OPTIONAL_DETAIL_NO_SPEC_FOR_TRIVIAL_TYPES
#endif
#if __cplusplus >= 201103L
# if BOOST_WORKAROUND(BOOST_GCC, >= 50000) &&
# define BOOST_OPTIONAL_DETAIL_USE_STD_TYPE_TRAITS
# elif (defined BOOST_CLANG)
# define BOOST_OPTIONAL_DETAIL_USE_STD_TYPE_TRAITS
# endif
#endif #endif
#ifdef BOOST_OPTIONAL_CONFIG_NO_POD_SPEC #ifdef BOOST_OPTIONAL_CONFIG_NO_POD_SPEC

View File

@ -20,6 +20,10 @@
#include <new> #include <new>
#include <iosfwd> #include <iosfwd>
#ifdef BOOST_OPTIONAL_DETAIL_USE_STD_TYPE_TRAITS
# include <type_traits>
#endif
#include <boost/assert.hpp> #include <boost/assert.hpp>
#include <boost/core/addressof.hpp> #include <boost/core/addressof.hpp>
#include <boost/core/enable_if.hpp> #include <boost/core/enable_if.hpp>
@ -828,10 +832,16 @@ struct is_type_trivially_copyable
namespace optional_config { namespace optional_config {
#ifndef BOOST_OPTIONAL_DETAIL_USE_STD_TYPE_TRAITS
# define BOOST_OPTIONAL_DETAIL_HAS_TRIVIAL_CTOR(T) BOOST_HAS_TRIVIAL_CONSTRUCTOR(T)
#else
# define BOOST_OPTIONAL_DETAIL_HAS_TRIVIAL_CTOR(T) std::is_trivially_default_constructible<T>::value
#endif
#ifndef BOOST_OPTIONAL_DETAIL_NO_SPEC_FOR_TRIVIAL_TYPES #ifndef BOOST_OPTIONAL_DETAIL_NO_SPEC_FOR_TRIVIAL_TYPES
template <typename T> template <typename T>
struct is_type_trivial struct is_type_trivial
: boost::conditional< (optional_detail::is_type_trivially_copyable<T>::value && BOOST_HAS_TRIVIAL_CONSTRUCTOR(T)) || : boost::conditional< (optional_detail::is_type_trivially_copyable<T>::value && BOOST_OPTIONAL_DETAIL_HAS_TRIVIAL_CTOR(T)) ||
(boost::is_scalar<T>::value && !boost::is_const<T>::value && !boost::is_volatile<T>::value) (boost::is_scalar<T>::value && !boost::is_const<T>::value && !boost::is_volatile<T>::value)
, boost::true_type, boost::false_type>::type , boost::true_type, boost::false_type>::type
{}; {};