diff --git a/.travis.yml b/.travis.yml index 2903ba1..b605585 100644 --- a/.travis.yml +++ b/.travis.yml @@ -151,6 +151,7 @@ matrix: - llvm-toolchain-precise-3.9 - os: linux + dist: trusty compiler: clang++-4.0 env: TOOLSET=clang COMPILER=clang++-4.0 CXXSTD=03,11,14,1z addons: @@ -162,6 +163,7 @@ matrix: - llvm-toolchain-trusty-4.0 - os: linux + dist: trusty compiler: clang++-5.0 env: TOOLSET=clang COMPILER=clang++-5.0 CXXSTD=03,11,14,1z addons: diff --git a/include/boost/optional/detail/optional_trivially_copyable_base.hpp b/include/boost/optional/detail/optional_trivially_copyable_base.hpp index 5a37eac..2cabf9a 100644 --- a/include/boost/optional/detail/optional_trivially_copyable_base.hpp +++ b/include/boost/optional/detail/optional_trivially_copyable_base.hpp @@ -359,7 +359,7 @@ class tc_optional_base : public optional_tag template void construct ( Expr const& factory, in_place_factory_base const* ) { - boost_optional_detail::construct(factory, m_storage.address()); + boost_optional_detail::construct(factory, boost::addressof(m_storage)); m_initialized = true ; } diff --git a/test/optional_test_constructible_from_other.cpp b/test/optional_test_constructible_from_other.cpp index e106b69..af85686 100644 --- a/test/optional_test_constructible_from_other.cpp +++ b/test/optional_test_constructible_from_other.cpp @@ -26,12 +26,14 @@ struct size_tag {}; template< typename T, typename U > struct is_constructible { - template< typename T1, typename U1 > - static yes_type check_helper(size_tag< sizeof(static_cast< T1 >(U1())) >*); - template< typename T1, typename U1 > + static U& get(); + + template< typename T1 > + static yes_type check_helper(size_tag< sizeof(static_cast< T1 >(get())) >*); + template< typename T1 > static no_type check_helper(...); - static const bool value = sizeof(check_helper< T, U >(0)) == sizeof(yes_type); + static const bool value = sizeof(check_helper< T >(0)) == sizeof(yes_type); }; template< typename T > diff --git a/test/optional_test_inplace_factory.cpp b/test/optional_test_inplace_factory.cpp index 1e852f0..4be9930 100644 --- a/test/optional_test_inplace_factory.cpp +++ b/test/optional_test_inplace_factory.cpp @@ -31,10 +31,10 @@ struct Guard std::string str; Guard() : num() {} Guard(double num_, std::string str_) : num(num_), str(str_) {} - + friend bool operator==(const Guard& lhs, const Guard& rhs) { return lhs.num == rhs.num && lhs.str == rhs.str; } friend bool operator!=(const Guard& lhs, const Guard& rhs) { return !(lhs == rhs); } - + private: Guard(const Guard&); Guard& operator=(const Guard&); @@ -44,26 +44,30 @@ void test_ctor() { #ifndef BOOST_OPTIONAL_NO_INPLACE_FACTORY_SUPPORT Guard g0, g1(1.0, "one"), g2(2.0, "two"); - + boost::optional og0 ( boost::in_place() ); boost::optional og1 ( boost::in_place(1.0, "one") ); boost::optional og1_( boost::in_place(1.0, "one") ); boost::optional og2 ( boost::in_place(2.0, "two") ); - + BOOST_TEST(og0); BOOST_TEST(og1); BOOST_TEST(og1_); BOOST_TEST(og2); - + BOOST_TEST(*og0 == g0); BOOST_TEST(*og1 == g1); BOOST_TEST(*og1_ == g1); BOOST_TEST(*og2 == g2); - + BOOST_TEST(og1_ == og1); BOOST_TEST(og1_ != og2); BOOST_TEST(og1_ != og0); -#endif + + boost::optional o( boost::in_place(5) ); + BOOST_TEST(o); + BOOST_TEST(*o == 5); +#endif } void test_assign() @@ -71,27 +75,32 @@ void test_assign() #ifndef BOOST_OPTIONAL_NO_INPLACE_FACTORY_SUPPORT #ifndef BOOST_OPTIONAL_WEAK_OVERLOAD_RESOLUTION Guard g0, g1(1.0, "one"), g2(2.0, "two"); - + boost::optional og0, og1, og1_, og2; - + og0 = boost::in_place(); og1 = boost::in_place(1.0, "one"); og1_ = boost::in_place(1.0, "one"); og2 = boost::in_place(2.0, "two"); - + BOOST_TEST(og0); BOOST_TEST(og1); BOOST_TEST(og1_); BOOST_TEST(og2); - + BOOST_TEST(*og0 == g0); BOOST_TEST(*og1 == g1); BOOST_TEST(*og1_ == g1); BOOST_TEST(*og2 == g2); - + BOOST_TEST(og1_ == og1); BOOST_TEST(og1_ != og2); BOOST_TEST(og1_ != og0); + + boost::optional o; + o = boost::in_place(5); + BOOST_TEST(o); + BOOST_TEST(*o == 5); #endif #endif } @@ -101,4 +110,4 @@ int main() test_ctor(); test_assign(); return boost::report_errors(); -} \ No newline at end of file +} diff --git a/test/optional_test_path_assignment.cpp b/test/optional_test_path_assignment.cpp index f0c214a..0765c2d 100644 --- a/test/optional_test_path_assignment.cpp +++ b/test/optional_test_path_assignment.cpp @@ -15,6 +15,8 @@ #pragma hdrstop #endif +#ifndef BOOST_OPTIONAL_DETAIL_NO_IS_CONSTRUCTIBLE_TRAIT +#ifndef BOOST_OPTIONAL_DETAIL_NO_SFINAE_FRIENDLY_CONSTRUCTORS template struct void_t { @@ -49,6 +51,8 @@ struct Path #endif }; +#endif +#endif int main() diff --git a/test/optional_test_ref_converting_ctor.cpp b/test/optional_test_ref_converting_ctor.cpp index 81f3c0f..e31904b 100644 --- a/test/optional_test_ref_converting_ctor.cpp +++ b/test/optional_test_ref_converting_ctor.cpp @@ -93,7 +93,9 @@ template void test_all_const_cases() { test_converting_ctor(); +#ifndef BOOST_OPTIONAL_CONFIG_NO_PROPER_CONVERT_FROM_CONST_INT test_converting_ctor(); +#endif test_converting_ctor_for_noconst_const(); }