7#if !defined(ASYNC_MQTT_UTIL_PACKET_VARIANT_OPERATOR_HPP)
8#define ASYNC_MQTT_UTIL_PACKET_VARIANT_OPERATOR_HPP
12#include <async_mqtt/packet/packet_variant.hpp>
13#include <async_mqtt/packet/packet_traits.hpp>
17namespace as = boost::asio;
19template <std::
size_t PacketIdBytes>
20inline bool basic_packet_variant_equal(
21 basic_packet_variant<PacketIdBytes>
const& lhs,
22 basic_packet_variant<PacketIdBytes>
const& rhs
25 auto [lhs_b, lhs_e] = make_packet_range(lhs_cbs);
27 auto rhs_cbs = rhs.const_buffer_sequence();
28 auto [rhs_b, rhs_e] = make_packet_range(rhs_cbs);
30 return std::equal(lhs_b, lhs_e, rhs_b, rhs_e);
33inline bool packet_variant_equal(
34 packet_variant
const& lhs,
35 packet_variant
const& rhs
37 return basic_packet_variant_equal<2>(lhs, rhs);
40template <std::
size_t PacketIdBytes>
41inline bool operator==(
42 basic_packet_variant<PacketIdBytes>
const& lhs,
43 basic_packet_variant<PacketIdBytes>
const& rhs
45 return basic_packet_variant_equal<PacketIdBytes>(lhs, rhs);
48inline bool operator==(
49 packet_variant
const& lhs,
50 packet_variant
const& rhs
52 return packet_variant_equal(lhs, rhs);
55template <std::
size_t PacketIdBytes>
56inline bool basic_packet_variant_less_than(
57 basic_packet_variant<PacketIdBytes>
const& lhs,
58 basic_packet_variant<PacketIdBytes>
const& rhs
61 auto [lhs_b, lhs_e] = make_packet_range(lhs_cbs);
63 auto rhs_cbs = rhs.const_buffer_sequence();
64 auto [rhs_b, rhs_e] = make_packet_range(rhs_cbs);
66 return std::lexicographical_compare(lhs_b, lhs_e, rhs_b, rhs_e);
69inline bool packet_variant_less_than(
70 packet_variant
const& lhs,
71 packet_variant
const& rhs
73 return basic_packet_variant_less_than<2>(lhs, rhs);
76template <std::
size_t PacketIdBytes>
78 basic_packet_variant<PacketIdBytes>
const& lhs,
79 basic_packet_variant<PacketIdBytes>
const& rhs
81 return basic_packet_variant_less_than<PacketIdBytes>(lhs, rhs);
85 packet_variant
const& lhs,
86 packet_variant
const& rhs
88 return packet_variant_less_than(lhs, rhs);
std::vector< as::const_buffer > const_buffer_sequence() const
Create const buffer sequence it is for boost asio APIs.
Definition packet_variant.hpp:166