Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion include/msg/message.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ template <stdx::ct_string Name> struct field_name {
using name_t = stdx::cts_t<Name>;

// NOLINTNEXTLINE(misc-unconventional-assign-operator)
template <typename T> constexpr auto operator=(T value) {
template <typename T> constexpr auto operator=(T value) const {
return field_value<Name, T>{value};
}

Expand Down
9 changes: 9 additions & 0 deletions test/msg/message.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,15 @@ TEST_CASE("construct with field values", "[message]") {
CHECK(0x0042'd00d == data[1]);
}

TEST_CASE("use field names as template args", "[message]") {
auto msg = []<auto F>() {
return test_msg{F = 0xba11};
}.template operator()<"f1"_field>();

auto const data = msg.data();
CHECK(0x8000'ba11 == data[0]);
}

TEST_CASE("construct with field defaults", "[message]") {
test_msg msg{};

Expand Down
Loading