diff --git a/include/boost/smart_ptr/shared_ptr.hpp b/include/boost/smart_ptr/shared_ptr.hpp index 7237a7d..0405ab0 100644 --- a/include/boost/smart_ptr/shared_ptr.hpp +++ b/include/boost/smart_ptr/shared_ptr.hpp @@ -1175,6 +1175,13 @@ template D const * basic_get_local_deleter( D const *, shared_ } // namespace detail +#if defined(__cpp_deduction_guides) + +template shared_ptr( weak_ptr ) -> shared_ptr; +template shared_ptr( std::unique_ptr ) -> shared_ptr; + +#endif + } // namespace boost #if defined( BOOST_SP_DISABLE_DEPRECATED ) diff --git a/include/boost/smart_ptr/weak_ptr.hpp b/include/boost/smart_ptr/weak_ptr.hpp index 5230f35..07ba189 100644 --- a/include/boost/smart_ptr/weak_ptr.hpp +++ b/include/boost/smart_ptr/weak_ptr.hpp @@ -264,6 +264,12 @@ template void swap(weak_ptr & a, weak_ptr & b) BOOST_SP_NOEXCEPT a.swap(b); } +#if defined(__cpp_deduction_guides) + +template weak_ptr( shared_ptr ) -> weak_ptr; + +#endif + } // namespace boost #endif // #ifndef BOOST_SMART_PTR_WEAK_PTR_HPP_INCLUDED diff --git a/test/Jamfile b/test/Jamfile index f055d21..8e121b8 100644 --- a/test/Jamfile +++ b/test/Jamfile @@ -352,3 +352,7 @@ run allocate_unique_noinit_test.cpp ; run allocate_unique_test.cpp ; run allocate_unique_throws_test.cpp ; run allocate_unique_value_test.cpp ; + +run sp_guides_test.cpp ; +run sp_guides_test2.cpp ; +run wp_guides_test.cpp ; diff --git a/test/sp_guides_test.cpp b/test/sp_guides_test.cpp new file mode 100644 index 0000000..a7c6ff4 --- /dev/null +++ b/test/sp_guides_test.cpp @@ -0,0 +1,25 @@ +// Copyright 2020 Peter Dimov +// Distributed under the Boost Software License, Version 1.0. +// https://www.boost.org/LICENSE_1_0.txt + +#if defined(__cpp_deduction_guides) + +#include +#include + +int main() +{ + boost::shared_ptr p1( new int ); + boost::weak_ptr p2( p1 ); + boost::shared_ptr p3( p2 ); +} + +#else + +#include + +BOOST_PRAGMA_MESSAGE( "Skipping test because __cpp_deduction_guides is not defined" ) + +int main() {} + +#endif diff --git a/test/sp_guides_test2.cpp b/test/sp_guides_test2.cpp new file mode 100644 index 0000000..e7ccfbc --- /dev/null +++ b/test/sp_guides_test2.cpp @@ -0,0 +1,23 @@ +// Copyright 2020 Peter Dimov +// Distributed under the Boost Software License, Version 1.0. +// https://www.boost.org/LICENSE_1_0.txt + +#if defined(__cpp_deduction_guides) + +#include +#include + +int main() +{ + boost::shared_ptr p2( std::unique_ptr( new int ) ); +} + +#else + +#include + +BOOST_PRAGMA_MESSAGE( "Skipping test because __cpp_deduction_guides is not defined" ) + +int main() {} + +#endif diff --git a/test/wp_guides_test.cpp b/test/wp_guides_test.cpp new file mode 100644 index 0000000..92f95a0 --- /dev/null +++ b/test/wp_guides_test.cpp @@ -0,0 +1,24 @@ +// Copyright 2020 Peter Dimov +// Distributed under the Boost Software License, Version 1.0. +// https://www.boost.org/LICENSE_1_0.txt + +#if defined(__cpp_deduction_guides) + +#include +#include + +int main() +{ + boost::shared_ptr p1( new int ); + boost::weak_ptr p2( p1 ); +} + +#else + +#include + +BOOST_PRAGMA_MESSAGE( "Skipping test because __cpp_deduction_guides is not defined" ) + +int main() {} + +#endif