GCC 4.4.7: boost::in_place & Assignment

Assigning a boost::in_place_factory to a boost::optional templated on a
type which was trivially copyable failed to compile under GCC 4.4.7.
This commit is contained in:
Robert Leahy
2019-12-22 16:13:53 -05:00
parent d07ae78901
commit 9581804efa
2 changed files with 8 additions and 1 deletions

View File

@ -359,7 +359,7 @@ class tc_optional_base : public optional_tag
template<class Expr> template<class Expr>
void construct ( Expr const& factory, in_place_factory_base const* ) void construct ( Expr const& factory, in_place_factory_base const* )
{ {
boost_optional_detail::construct<value_type>(factory, m_storage.address()); boost_optional_detail::construct<value_type>(factory, boost::addressof(m_storage));
m_initialized = true ; m_initialized = true ;
} }

View File

@ -63,6 +63,9 @@ void test_ctor()
BOOST_TEST(og1_ == og1); BOOST_TEST(og1_ == og1);
BOOST_TEST(og1_ != og2); BOOST_TEST(og1_ != og2);
BOOST_TEST(og1_ != og0); BOOST_TEST(og1_ != og0);
boost::optional<unsigned int> o( boost::in_place(5) );
BOOST_TEST(o && (*o == 5));
#endif #endif
} }
@ -92,6 +95,10 @@ void test_assign()
BOOST_TEST(og1_ == og1); BOOST_TEST(og1_ == og1);
BOOST_TEST(og1_ != og2); BOOST_TEST(og1_ != og2);
BOOST_TEST(og1_ != og0); BOOST_TEST(og1_ != og0);
boost::optional<unsigned int> o;
o = boost::in_place(5);
BOOST_TEST(o && (*o == 5));
#endif #endif
#endif #endif
} }