...
This commit is contained in:
@@ -489,7 +489,11 @@ struct MccNetMessageValidKeywords {
|
||||
static_assert(mcc_netmsg_valid_keys_c<MccNetMessageValidKeywords>, "");
|
||||
|
||||
|
||||
template <mcc_netmsg_valid_keys_c BASE_T, traits::mcc_char_range BYTEREPR_T>
|
||||
template <typename T>
|
||||
concept mcc_netmessage_c = requires(T t) { T(); };
|
||||
|
||||
template <mcc::traits::mcc_char_range BYTEREPR_T = std::string_view,
|
||||
mcc_netmsg_valid_keys_c BASE_T = MccNetMessageValidKeywords>
|
||||
class MccNetMessage
|
||||
{
|
||||
public:
|
||||
@@ -675,6 +679,11 @@ protected:
|
||||
(*this)(el, bytes);
|
||||
}
|
||||
}
|
||||
} else if constexpr (std::same_as<T, std::error_code>) {
|
||||
std::format_to(std::back_inserter(bytes), "{}{}{}{}{}", value.value(),
|
||||
MCC_COMMPROTO_RANGEPARAM_DELIM_SEQ, value.message(), MCC_COMMPROTO_RANGEPARAM_DELIM_SEQ,
|
||||
value.category().name());
|
||||
} else if constexpr (std::same_as<T, MccNetMessage>) {
|
||||
} else if constexpr (std::formattable<T, char>) {
|
||||
std::format_to(std::back_inserter(bytes), "{}", value);
|
||||
} else {
|
||||
@@ -706,6 +715,12 @@ public:
|
||||
fromCharRange(msg);
|
||||
}
|
||||
|
||||
// constexpr MccNetMessage(const BYTEREPR_T& msg)
|
||||
// requires traits::mcc_input_char_range<BYTEREPR_T>
|
||||
// {
|
||||
// fromCharRange(msg);
|
||||
// }
|
||||
|
||||
template <traits::mcc_input_char_range KT>
|
||||
constexpr bool withKey(const KT& key)
|
||||
{
|
||||
@@ -987,6 +1002,7 @@ protected:
|
||||
};
|
||||
};
|
||||
|
||||
static_assert(MccNetMessage<MccNetMessageValidKeywords, std::string_view>{"ACK"}.withKey("ACK"));
|
||||
static_assert(MccNetMessage<std::string, MccNetMessageValidKeywords>{"ACK"}.withKey("ACK"));
|
||||
static_assert(MccNetMessage{"ACK"}.withKey("ACK"));
|
||||
|
||||
} // namespace mcc::network
|
||||
|
||||
Reference in New Issue
Block a user