File tree Expand file tree Collapse file tree
include/bitcoin/system/data Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -32,14 +32,22 @@ BC_PUSH_WARNING(NO_VALUE_OR_CONST_REF_SHARED_PTR)
3232
3333// / shared_ptr
3434// / ---------------------------------------------------------------------------
35+ // / Some of these are just used to suppress noexcept warnings.
3536
3637// / Create shared pointer to non-const from moved instance.
3738template <typename Type>
38- inline std::shared_ptr<Type> make_shared (Type&& value) NOEXCEPT
39+ inline std::shared_ptr<Type> move_shared (Type&& value) NOEXCEPT
3940{
4041 return std::make_shared<Type>(std::forward<Type>(value));
4142}
4243
44+ // / Create shared pointer to an in-place constructed instance.
45+ template <typename Type, typename ...Args>
46+ inline std::shared_ptr<Type> emplace_shared (Args&&... args) NOEXCEPT
47+ {
48+ return std::make_shared<Type>(std::forward<Args>(args)...);
49+ }
50+
4351// / Create default shared pointer.
4452template <typename Type>
4553inline std::shared_ptr<Type> to_shared () NOEXCEPT
Original file line number Diff line number Diff line change @@ -31,17 +31,26 @@ struct type
3131 int right;
3232};
3333
34+ // emplace_shared
35+
36+ using test_string_shared_ptr = std::shared_ptr<std::string>;
37+
38+ BOOST_AUTO_TEST_CASE (memory__emplace_shared__array_move__expected_values)
39+ {
40+ const test_string_shared_ptr ptr = system::emplace_shared<std::string>(" test" );
41+ }
42+
3443// make_shared
3544
3645using test_array_shared_ptr = std::shared_ptr<data_array<3 >>;
3746
3847BOOST_AUTO_TEST_CASE (memory__make_shared__array_move__expected_values)
3948{
40- const test_array_shared_ptr ptr = make_shared <data_array<3 >>(data_array<3 >{ 1 , 2 , 3 });
49+ const test_array_shared_ptr ptr = system::move_shared <data_array<3 >>(data_array<3 >{ 1 , 2 , 3 });
4150 BOOST_REQUIRE_EQUAL (ptr->at (0 ), 1 );
4251 BOOST_REQUIRE_EQUAL (ptr->at (1 ), 2 );
4352 BOOST_REQUIRE_EQUAL (ptr->at (2 ), 3 );
44- }
53+ }
4554
4655// to_shared
4756
You can’t perform that action at this time.
0 commit comments