Unverified Commit 1855e8e0 authored by Noir's avatar Noir Committed by GitHub

Merge pull request #1279

Make message view API more robust
parents 3615a07f cbe2b02f
......@@ -11,6 +11,12 @@ is based on [Keep a Changelog](https://keepachangelog.com).
to process metrics even when not configuring CAF to export metrics to
Prometheus via HTTP.
### Changed
- Message views now perform the type-check in their constructor. With this
change, the `make_*` utility functions are no longer mandatory and users may
instead simply construct the view directly.
## Fixed
- Printing a `config_value` that contains a zero duration `timespan` now
......
......@@ -21,7 +21,7 @@ public:
}
explicit const_typed_message_view(const message& msg) noexcept
: ptr_(msg.cptr()) {
: ptr_(msg.types() == make_type_id_list<Ts...>() ? msg.cptr() : nullptr) {
// nop
}
......@@ -63,9 +63,7 @@ auto to_tuple(const_typed_message_view<Ts...> xs) {
template <class... Ts>
auto make_const_typed_message_view(const message& msg) {
if (msg.types() == make_type_id_list<Ts...>())
return const_typed_message_view<Ts...>{msg};
return const_typed_message_view<Ts...>{};
}
template <class... Ts>
......
......@@ -18,7 +18,8 @@ public:
// nop
}
explicit typed_message_view(message& msg) : ptr_(msg.ptr()) {
explicit typed_message_view(message& msg)
: ptr_(msg.types() == make_type_id_list<Ts...>() ? msg.ptr() : nullptr) {
// nop
}
......@@ -48,9 +49,7 @@ auto& get(typed_message_view<Ts...> x) {
template <class... Ts>
auto make_typed_message_view(message& msg) {
if (msg.types() == make_type_id_list<Ts...>())
return typed_message_view<Ts...>{msg};
return typed_message_view<Ts...>{};
}
} // namespace caf
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment