summaryrefslogtreecommitdiff
path: root/Rx/v2/src
diff options
context:
space:
mode:
authorKirk Shoop <kirk.shoop@microsoft.com>2014-07-15 22:02:19 -0700
committerKirk Shoop <kirk.shoop@microsoft.com>2014-07-15 22:02:19 -0700
commit638ec22f5a6073f15829b542577afc79e163d7cf (patch)
treeaf170d51b6c0b6d0770f6789f2758414fc5c920e /Rx/v2/src
parent71044820972aef3cef3295d1cdbf6faa2a74d872 (diff)
downloadRxCpp-638ec22f5a6073f15829b542577afc79e163d7cf.tar.gz
fixes some compilation issues adds a start_with ish thang
Diffstat (limited to 'Rx/v2/src')
-rw-r--r--Rx/v2/src/rxcpp/rx-observable.hpp37
-rw-r--r--Rx/v2/src/rxcpp/rx-util.hpp8
-rw-r--r--Rx/v2/src/rxcpp/sources/rx-iterate.hpp4
3 files changed, 44 insertions, 5 deletions
diff --git a/Rx/v2/src/rxcpp/rx-observable.hpp b/Rx/v2/src/rxcpp/rx-observable.hpp
index f2301bf..70c16a9 100644
--- a/Rx/v2/src/rxcpp/rx-observable.hpp
+++ b/Rx/v2/src/rxcpp/rx-observable.hpp
@@ -612,7 +612,7 @@ public:
template<class Coordination, class Selector, class... ObservableN>
struct defer_combine_latest : public defer_observable<
- rxu::all_true<is_coordination<Coordination>::value, !is_observable<Selector>::value, is_observable<ObservableN>::value...>,
+ rxu::all_true<is_coordination<Coordination>::value, !is_coordination<Selector>::value, !is_observable<Selector>::value, is_observable<ObservableN>::value...>,
this_type,
rxo::detail::combine_latest, Coordination, Selector, ObservableN...>
{
@@ -747,8 +747,8 @@ public:
/// for each item from this observable reduce it by adding to the previous values.
///
auto sum() const
- -> typename defer_reduce<rxu::defer_seed_type<rxo::detail::initialize_seeder, T>, rxu::defer_type<std::plus, T>, rxu::defer_type<identity_for, T>>::observable_type {
- return defer_reduce<rxu::defer_seed_type<rxo::detail::initialize_seeder, T>, rxu::defer_type<std::plus, T>, rxu::defer_type<identity_for, T>>::make(source_operator, std::plus<T>(), identity_for<T>(), rxo::detail::initialize_seeder<T>().seed());
+ -> typename defer_reduce<rxu::defer_seed_type<rxo::detail::initialize_seeder, T>, rxu::plus, rxu::defer_type<identity_for, T>>::observable_type {
+ return defer_reduce<rxu::defer_seed_type<rxo::detail::initialize_seeder, T>, rxu::plus, rxu::defer_type<identity_for, T>>::make(source_operator, rxu::plus(), identity_for<T>(), rxo::detail::initialize_seeder<T>().seed());
}
/// average ->
@@ -888,6 +888,32 @@ public:
return observable<T, rxo::detail::repeat<T, this_type, Count>>(
rxo::detail::repeat<T, this_type, Count>(*this, t));
}
+#if 0
+
+// causes infinite compile time recursion
+
+ template<class Coordination, class Value0>
+ struct defer_start_with_from : public defer_observable<
+ rxu::all_true<
+ is_coordination<Coordination>::value,
+ std::is_convertible<Value0, value_type>::value>,
+ this_type,
+ rxo::detail::concat, observable<value_type>, observable<observable<value_type>>, Coordination>
+ {
+ };
+
+ /// start_with ->
+ /// All sources must be synchronized! This means that calls across all the subscribers must be serial.
+ ///
+ ///
+ template<class Value0, class... ValueN>
+ auto start_with(Value0 v0, ValueN... vn) const
+ -> typename std::enable_if<
+ defer_start_with_from<identity_one_worker, Value0>::value,
+ typename defer_start_with_from<identity_one_worker, Value0>::observable_type>::type {
+ return defer_start_with_from<identity_one_worker, Value0>::make(*this, rxs::from(rxs::from(value_type(v0), value_type(vn)...).as_dynamic(), this->as_dynamic()), identity_immediate());
+ }
+#endif
};
template<class T, class SourceOperator>
@@ -1017,6 +1043,11 @@ public:
-> decltype(rxs::error<T>(std::forward<Exception>(e), std::move(cn))) {
return rxs::error<T>(std::forward<Exception>(e), std::move(cn));
}
+ template<class Observable, class Value0, class... ValueN>
+ static auto start_with(Observable o, Value0 v0, ValueN... vn)
+ -> decltype(rxs::from(typename Observable::value_type(v0), typename Observable::value_type(vn)...).concat(o)) {
+ return rxs::from(typename Observable::value_type(v0), typename Observable::value_type(vn)...).concat(o);
+ }
};
diff --git a/Rx/v2/src/rxcpp/rx-util.hpp b/Rx/v2/src/rxcpp/rx-util.hpp
index 6f71c97..06da93e 100644
--- a/Rx/v2/src/rxcpp/rx-util.hpp
+++ b/Rx/v2/src/rxcpp/rx-util.hpp
@@ -253,6 +253,14 @@ struct resolve_type<defer_seed_type<Deferred, AN...>>
typedef typename defer_seed_type<Deferred, AN...>::type type;
};
+struct plus
+{
+ template <class LHS, class RHS>
+ auto operator()(LHS&& lhs, RHS&& rhs) const
+ -> decltype(std::forward<LHS>(lhs) + std::forward<RHS>(rhs))
+ { return std::forward<LHS>(lhs) + std::forward<RHS>(rhs); }
+};
+
template<class OStream>
struct println_function
{
diff --git a/Rx/v2/src/rxcpp/sources/rx-iterate.hpp b/Rx/v2/src/rxcpp/sources/rx-iterate.hpp
index 23107da..4c1fbef 100644
--- a/Rx/v2/src/rxcpp/sources/rx-iterate.hpp
+++ b/Rx/v2/src/rxcpp/sources/rx-iterate.hpp
@@ -159,14 +159,14 @@ auto from(Coordination cn)
template<class Value0, class... ValueN>
auto from(Value0 v0, ValueN... vn)
-> typename std::enable_if<!is_coordination<Value0>::value,
- decltype(iterate(std::array<Value0, sizeof...(ValueN) + 1>(), identity_immediate()))>::type {
+ decltype(iterate(std::array<Value0, sizeof...(ValueN) + 1>{v0, vn...}, identity_immediate()))>::type {
std::array<Value0, sizeof...(ValueN) + 1> c = {v0, vn...};
return iterate(std::move(c), identity_immediate());
}
template<class Coordination, class Value0, class... ValueN>
auto from(Coordination cn, Value0 v0, ValueN... vn)
-> typename std::enable_if<is_coordination<Coordination>::value,
- decltype(iterate(std::array<Value0, sizeof...(ValueN) + 1>(), std::move(cn)))>::type {
+ decltype(iterate(std::array<Value0, sizeof...(ValueN) + 1>{v0, vn...}, std::move(cn)))>::type {
std::array<Value0, sizeof...(ValueN) + 1> c = {v0, vn...};
return iterate(std::move(c), std::move(cn));
}