boost-0002-Fix-compilation-of-Boost.Variants-move-assignment.patch 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. Fix compilation of Boost.Variants move assignment for situations when one of the variant template classes has nothrow copy constructor and throwing move constructor (refs #8772)
  2. Fixes compilation error:
  3. .../output/host/usr/arm-buildroot-linux-gnueabihf/sysroot/usr/include/boost/variant/variant.hpp: In member function 'void boost::variant<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19>::move_assigner::internal_visit(RhsT&, int) [with RhsT = boost::shared_ptr<void>, T0_ = boost::shared_ptr<void>, T1 = boost::signals2::detail::foreign_void_shared_ptr, T2 = boost::detail::variant::void_, ..., T18 = boost::detail::variant::void_, T19 = boost::detail::variant::void_]':
  4. ...
  5. .../output/host/usr/arm-buildroot-linux-gnueabihf/sysroot/usr/include/boost/variant/variant.hpp:2058:13: error: no matching function for call to 'boost::variant<boost::shared_ptr<void>, boost::signals2::detail::foreign_void_shared_ptr>::move_assigner::assign_impl(boost::shared_ptr<void>&, nothrow_copy, nothrow_move_constructor, boost::variant<boost::shared_ptr<void>, boost::signals2::detail::foreign_void_shared_ptr>::has_fallback_type_)'
  6. Reported here: https://svn.boost.org/trac/boost/ticket/8772
  7. Signed-off-by: Luca Ceresoli <luca@lucaceresoli.net>
  8. Backported-from: https://svn.boost.org/trac/boost/changeset/85080
  9. --- a/boost/variant/variant.hpp (revision 85079)
  10. +++ b/boost/variant/variant.hpp (revision 85080)
  11. @@ -1981,5 +1981,5 @@
  12. private: // helpers, for internal visitor interface (below)
  13. - template <typename RhsT, typename B1, typename B2>
  14. + template <typename RhsT, typename B2>
  15. void assign_impl(
  16. RhsT& rhs_content
  17. --- a/libs/variant/test/rvalue_test.cpp (revision 85079)
  18. +++ b/libs/variant/test/rvalue_test.cpp (revision 85080)
  19. @@ -197,4 +197,19 @@
  20. #endif
  21. +struct nothrow_copyable_throw_movable {
  22. + nothrow_copyable_throw_movable(){}
  23. + nothrow_copyable_throw_movable(const nothrow_copyable_throw_movable&) BOOST_NOEXCEPT {}
  24. +#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
  25. + nothrow_copyable_throw_movable(nothrow_copyable_throw_movable&&) BOOST_NOEXCEPT_IF(false) {}
  26. +#endif
  27. +};
  28. +
  29. +// This test is created to cover the following situation:
  30. +// https://svn.boost.org/trac/boost/ticket/8772
  31. +void run_tricky_compilation_test()
  32. +{
  33. + boost::variant<int, nothrow_copyable_throw_movable> v;
  34. + v = nothrow_copyable_throw_movable();
  35. +}
  36. int test_main(int , char* [])
  37. @@ -204,4 +219,5 @@
  38. run_move_only();
  39. run_moves_are_noexcept();
  40. + run_tricky_compilation_test();
  41. return 0;
  42. }