Skip to content

Fix build with Boost 1.86.0. #1247

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 13 additions & 9 deletions hazelcast/include/hazelcast/client/protocol/ClientMessage.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,11 @@
namespace hazelcast {
namespace util {
class ByteBuffer;

template<class T>
struct is_trivial_or_uuid : std::is_trivial<T> {};
template<>
struct is_trivial_or_uuid<boost::uuids::uuid> : std::true_type {};
}

namespace cp {
Expand Down Expand Up @@ -594,7 +599,7 @@ class HAZELCAST_API ClientMessage
std::is_same<std::pair<typename T::value_type::first_type,
typename T::value_type::second_type>,
typename T::value_type>::value &&
std::is_trivial<typename T::value_type::first_type>::value &&
hazelcast::util::is_trivial_or_uuid<typename T::value_type::first_type>::value &&
std::is_trivial<typename T::value_type::second_type>::value,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
std::is_trivial<typename T::value_type::second_type>::value,
hazelcast::util::is_trivial_or_uuid<typename T::value_type::second_type>::value,

there are 6 places in ClientMessage.h which uses std::is_trivial and all needs to change right?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have to admit I don't really know what this code does; I just checked where they presumably were supposed to go before.

A use of is_trivial only needs to change if you expect that thing to accept boost::uuid in that place.

I think I got all the get overloads, or did I miss one?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@BillyONeal Just sent an update commit for the missing parts. Can you review them if you see any problems. And then, we can merge if the PR is green. It would still be good to see if this code would work in latest boost versions.

T>::type
get()
Expand Down Expand Up @@ -625,7 +630,7 @@ class HAZELCAST_API ClientMessage
std::is_same<std::pair<typename T::value_type::first_type,
typename T::value_type::second_type>,
typename T::value_type>::value &&
std::is_trivial<typename T::value_type::first_type>::value &&
hazelcast::util::is_trivial_or_uuid<typename T::value_type::first_type>::value &&
!std::is_trivial<typename T::value_type::second_type>::value,
T>::type
get()
Expand Down Expand Up @@ -1246,12 +1251,11 @@ class HAZELCAST_API ClientMessage
set(nil);
if (!nil) {
boost::endian::endian_reverse_inplace<int64_t>(
*reinterpret_cast<int64_t*>(uuid.data));
*reinterpret_cast<int64_t*>(&uuid.data[0]));
boost::endian::endian_reverse_inplace<int64_t>(
*reinterpret_cast<int64_t*>(uuid.data +
util::Bits::LONG_SIZE_IN_BYTES));
*reinterpret_cast<int64_t*>(&uuid.data[util::Bits::LONG_SIZE_IN_BYTES]));
std::memcpy(wr_ptr(sizeof(boost::uuids::uuid)),
uuid.data,
&uuid.data[0],
sizeof(boost::uuids::uuid));
} else {
wr_ptr(sizeof(boost::uuids::uuid));
Expand Down Expand Up @@ -1525,13 +1529,13 @@ class HAZELCAST_API ClientMessage
boost::uuids::uuid get_uuid()
{
boost::uuids::uuid u;
memcpy(&u.data,
memcpy(&u.data[0],
rd_ptr(sizeof(boost::uuids::uuid)),
sizeof(boost::uuids::uuid));
boost::endian::endian_reverse_inplace<int64_t>(
*reinterpret_cast<int64_t*>(u.data));
*reinterpret_cast<int64_t*>(&u.data[0]));
boost::endian::endian_reverse_inplace<int64_t>(
*reinterpret_cast<int64_t*>(u.data + util::Bits::LONG_SIZE_IN_BYTES));
*reinterpret_cast<int64_t*>(&u.data[util::Bits::LONG_SIZE_IN_BYTES]));
return u;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,11 +182,11 @@ class data_input
{
check_available(util::Bits::UUID_SIZE_IN_BYTES);
boost::uuids::uuid u;
std::memcpy(&u.data, &buffer_[pos_], util::Bits::UUID_SIZE_IN_BYTES);
std::memcpy(&u.data[0], &buffer_[pos_], util::Bits::UUID_SIZE_IN_BYTES);
pos_ += util::Bits::UUID_SIZE_IN_BYTES;
if (byte_order_ == boost::endian::order::little) {
boost::endian::endian_reverse_inplace<int64_t>(
*reinterpret_cast<int64_t*>(u.data));
*reinterpret_cast<int64_t*>(&u.data[0]));
boost::endian::endian_reverse_inplace<int64_t>(
*reinterpret_cast<int64_t*>(
&u.data[util::Bits::LONG_SIZE_IN_BYTES]));
Expand Down
17 changes: 1 addition & 16 deletions hazelcast/include/hazelcast/client/spi/impl/ClientInvocation.h
Original file line number Diff line number Diff line change
Expand Up @@ -210,22 +210,7 @@ class HAZELCAST_API ClientInvocation
const std::string& name,
int partition = UNASSIGNED_PARTITION,
const std::shared_ptr<connection::Connection>& conn = nullptr,
boost::uuids::uuid uuid = { 0x0,
0x0,
0x0,
0x0,
0x0,
0x0,
0x0,
0x0,
0x0,
0x0,
0x0,
0x0,
0x0,
0x0,
0x0,
0x0 });
boost::uuids::uuid uuid = {});

void invoke_on_selection();

Expand Down
2 changes: 1 addition & 1 deletion hazelcast/src/hazelcast/client/protocol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ operator<<(std::ostream& os, const ClientMessage& msg)
void
ClientMessage::set(unsigned char* /* memory */, boost::uuids::uuid uuid)
{
std::memcpy(wr_ptr(uuid.size()), uuid.data, uuid.size());
std::memcpy(wr_ptr(uuid.size()), &uuid.data[0], uuid.size());
}

void
Expand Down
4 changes: 2 additions & 2 deletions hazelcast/src/hazelcast/client/serialization.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -731,12 +731,12 @@ data_output::write(boost::uuids::uuid v)
}
if (byte_order_ == boost::endian::order::little) {
boost::endian::endian_reverse_inplace<int64_t>(
*reinterpret_cast<int64_t*>(v.data));
*reinterpret_cast<int64_t*>(&v.data[0]));
boost::endian::endian_reverse_inplace<int64_t>(
*reinterpret_cast<int64_t*>(&v.data[util::Bits::LONG_SIZE_IN_BYTES]));
}
output_stream_.insert(
output_stream_.end(), v.data, v.data + util::Bits::UUID_SIZE_IN_BYTES);
output_stream_.end(), &v.data[0], &v.data[util::Bits::LONG_SIZE_IN_BYTES]);
}

template<>
Expand Down
Loading