Skip to content

Commit 9a1f1bd

Browse files
authored
Merge pull request #1722 from evoskuil/master
Declare BOOST_BIND_NO_PLACEHOLDERS, include boost/bind, remove beast.
2 parents d24ffb2 + 59146e5 commit 9a1f1bd

File tree

4 files changed

+32
-7
lines changed

4 files changed

+32
-7
lines changed

include/bitcoin/system/boost.hpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,15 @@
2424
// warnings are included by define.hpp which follows boost includes.
2525
#include <bitcoin/system/warnings.hpp>
2626

27-
// Include boost only from here, so exception disable works.
27+
// Include boost only from here, so this exclusion works.
28+
// Avoid namespace conflict between boost::placeholders and std::placeholders.
29+
// This arises when including <functional>, which declares std::placeholders.
30+
// www.boost.org/doc/libs/1_78_0/boost/bind.hpp
31+
// Include boost only from here, so placeholders exclusion works.
32+
#define BOOST_BIND_NO_PLACEHOLDERS
33+
#include <boost/bind.hpp>
34+
2835
#include <boost/asio.hpp>
29-
#include <boost/beast.hpp>
3036
#include <boost/format.hpp>
3137
#include <boost/iostreams/stream.hpp>
3238
#include <boost/json.hpp>

include/bitcoin/system/data/memory.hpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,13 @@ BC_PUSH_WARNING(NO_VALUE_OR_CONST_REF_SHARED_PTR)
3333
/// shared_ptr
3434
/// ---------------------------------------------------------------------------
3535

36+
/// Create shared pointer to non-const from moved instance.
37+
template <typename Type>
38+
inline std::shared_ptr<Type> make_shared(Type&& value) NOEXCEPT
39+
{
40+
return std::make_shared<Type>(std::forward<Type>(value));
41+
}
42+
3643
/// Create default shared pointer.
3744
template <typename Type>
3845
inline std::shared_ptr<Type> to_shared() NOEXCEPT

src/define.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
*/
1919
#include <bitcoin/system/define.hpp>
2020

21-
// Required in source (cpp) I replaced for boost header only.
21+
// Required in source (cpp) for boost header only.
2222
#include <boost/json/src.hpp>
2323

2424
// This is a maintainer file to force rebuild of /system only.

test/data/memory.cpp

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,25 @@ struct type
3131
int right;
3232
};
3333

34+
// make_shared
35+
36+
using test_array_shared_ptr = std::shared_ptr<data_array<3>>;
37+
38+
BOOST_AUTO_TEST_CASE(memory__make_shared__array_move__expected_values)
39+
{
40+
const test_array_shared_ptr ptr = make_shared<data_array<3>>(data_array<3>{ 1, 2, 3 });
41+
BOOST_REQUIRE_EQUAL(ptr->at(0), 1);
42+
BOOST_REQUIRE_EQUAL(ptr->at(1), 2);
43+
BOOST_REQUIRE_EQUAL(ptr->at(2), 3);
44+
}
45+
3446
// to_shared
3547

36-
using test_array_shared_ptr = std::shared_ptr<const data_array<3>>;
48+
using test_const_array_shared_ptr = std::shared_ptr<const data_array<3>>;
3749

3850
BOOST_AUTO_TEST_CASE(memory__to_shared1__array_default__default_values)
3951
{
40-
const test_array_shared_ptr ptr = to_shared<data_array<3>>();
52+
const test_const_array_shared_ptr ptr = to_shared<data_array<3>>();
4153
BOOST_REQUIRE_EQUAL(ptr->at(0), 0);
4254
BOOST_REQUIRE_EQUAL(ptr->at(1), 0);
4355
BOOST_REQUIRE_EQUAL(ptr->at(2), 0);
@@ -46,15 +58,15 @@ BOOST_AUTO_TEST_CASE(memory__to_shared1__array_default__default_values)
4658
BOOST_AUTO_TEST_CASE(memory__to_shared5__array_copy__expected_values)
4759
{
4860
const data_array<3> copy{ 1, 2, 3 };
49-
const test_array_shared_ptr ptr = to_shared<data_array<3>>(copy);
61+
const test_const_array_shared_ptr ptr = to_shared<data_array<3>>(copy);
5062
BOOST_REQUIRE_EQUAL(ptr->at(0), 1);
5163
BOOST_REQUIRE_EQUAL(ptr->at(1), 2);
5264
BOOST_REQUIRE_EQUAL(ptr->at(2), 3);
5365
}
5466

5567
BOOST_AUTO_TEST_CASE(memory__to_shared5__array_move__expected_values)
5668
{
57-
const test_array_shared_ptr ptr = to_shared<data_array<3>>(data_array<3>{ 1, 2, 3 });
69+
const test_const_array_shared_ptr ptr = to_shared<data_array<3>>(data_array<3>{ 1, 2, 3 });
5870
BOOST_REQUIRE_EQUAL(ptr->at(0), 1);
5971
BOOST_REQUIRE_EQUAL(ptr->at(1), 2);
6072
BOOST_REQUIRE_EQUAL(ptr->at(2), 3);

0 commit comments

Comments
 (0)