Commit b713a845 authored by Dominik Charousset's avatar Dominik Charousset

Improve static assertions

parent df3f8be3
...@@ -607,6 +607,9 @@ auto observable<T>::merge(Inputs&&... xs) { ...@@ -607,6 +607,9 @@ auto observable<T>::merge(Inputs&&... xs) {
static_assert( static_assert(
sizeof...(Inputs) > 0, sizeof...(Inputs) > 0,
"merge without arguments expects this observable to emit observables"); "merge without arguments expects this observable to emit observables");
static_assert(
(std::is_same_v<Out, output_type_t<std::decay_t<Inputs>>> && ...),
"can only merge observables with the same observed type");
using impl_t = op::merge<Out>; using impl_t = op::merge<Out>;
return make_observable<impl_t>(ctx(), *this, std::forward<Inputs>(xs)...); return make_observable<impl_t>(ctx(), *this, std::forward<Inputs>(xs)...);
} }
...@@ -622,7 +625,10 @@ auto observable<T>::concat(Inputs&&... xs) { ...@@ -622,7 +625,10 @@ auto observable<T>::concat(Inputs&&... xs) {
} else { } else {
static_assert( static_assert(
sizeof...(Inputs) > 0, sizeof...(Inputs) > 0,
"merge without arguments expects this observable to emit observables"); "concat without arguments expects this observable to emit observables");
static_assert(
(std::is_same_v<Out, output_type_t<std::decay_t<Inputs>>> && ...),
"can only concatenate observables with the same observed type");
using impl_t = op::concat<Out>; using impl_t = op::concat<Out>;
return make_observable<impl_t>(ctx(), *this, std::forward<Inputs>(xs)...); return make_observable<impl_t>(ctx(), *this, std::forward<Inputs>(xs)...);
} }
......
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