1 // Copyright 2017 Peter Dimov 2 // Copyright 2017 Vinnie Falco 3 // Copyright 2018 Andrzej Krzemienski 4 // 5 // Distributed under the Boost Software License, Version 1.0. 6 // 7 // http://www.boost.org/LICENSE_1_0.txt 8 9 #include <boost/config.hpp> 10 11 #if defined(BOOST_NO_CXX11_DELETED_FUNCTIONS) 12 main()13int main() 14 { 15 } 16 17 #else 18 19 #include <boost/optional.hpp> 20 #include <utility> 21 22 class basic_multi_buffer; 23 24 class const_buffers_type // a similar declaration in boost.beast had problem 25 { // with boost opitonal 26 basic_multi_buffer const* b_; 27 28 friend class basic_multi_buffer; 29 30 explicit 31 const_buffers_type(basic_multi_buffer const& b); 32 33 public: 34 const_buffers_type() = delete; 35 const_buffers_type(const_buffers_type const&) = default; 36 const_buffers_type& operator=(const_buffers_type const&) = default; 37 }; 38 test_beast_example()39void test_beast_example() 40 { 41 // test if it even compiles 42 boost::optional< std::pair<const_buffers_type, int> > opt, opt2; 43 opt = opt2; 44 (void)opt; 45 } 46 47 struct NotDefaultConstructible // minimal class exposing the problem 48 { 49 NotDefaultConstructible() = delete; 50 }; 51 test_assign_for_non_default_constructible()52void test_assign_for_non_default_constructible() 53 { 54 // test if it even compiles 55 boost::optional<NotDefaultConstructible> opt, opt2; 56 opt = opt2; 57 (void)opt; 58 } 59 main()60int main() 61 { 62 test_beast_example(); 63 test_assign_for_non_default_constructible(); 64 } 65 66 #endif 67