RxCpp
The Reactive Extensions for Native (RxCpp) is a library for composing asynchronous and event-based programs using observable sequences and LINQ-style query operators in both C and C++.
rx-start_with.hpp
Go to the documentation of this file.
1 // Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information.
2 
3 #pragma once
4 
26 #if !defined(RXCPP_OPERATORS_RX_START_WITH_HPP)
27 #define RXCPP_OPERATORS_RX_START_WITH_HPP
28 
29 #include "../rx-includes.hpp"
30 #include "./rx-concat.hpp"
31 
32 namespace rxcpp {
33 
34 namespace operators {
35 
36 namespace detail {
37 
38 template<class... AN>
39 struct start_with_invalid_arguments {};
40 
41 template<class... AN>
42 struct start_with_invalid : public rxo::operator_base<start_with_invalid_arguments<AN...>> {
43  using type = observable<start_with_invalid_arguments<AN...>, start_with_invalid<AN...>>;
44 };
45 template<class... AN>
46 using start_with_invalid_t = typename start_with_invalid<AN...>::type;
47 
48 }
49 
52 template<class... AN>
53 auto start_with(AN&&... an)
55  return operator_factory<start_with_tag, AN...>(std::make_tuple(std::forward<AN>(an)...));
56 }
57 
58 }
59 
60 template<>
62 {
63  template<class Observable, class Value0, class... ValueN,
64  class Enabled = rxu::enable_if_all_true_type_t<
66  class From = decltype(rxs::from(rxu::decay_t<Value0>(std::declval<Value0>()), rxu::decay_t<ValueN>(std::declval<ValueN>())...))
67  >
68  static auto member(Observable&& o, Value0&& v0, ValueN&&... vn)
69  -> decltype(member_overload<concat_tag>::member(std::declval<From>(), std::forward<Observable>(o))) {
71  return member_overload<concat_tag>::member(first, std::forward<Observable>(o));
72  }
73 
74  template<class... AN>
75  static operators::detail::start_with_invalid_t<AN...> member(const AN&...) {
76  std::terminate();
77  return {};
78  static_assert(sizeof...(AN) == 10000, "start_with takes (Value0, optional ValueN...)");
79  }
80 };
81 
82 }
83 
84 #endif
Definition: rx-all.hpp:26
static operators::detail::start_with_invalid_t< AN... > member(const AN &...)
Definition: rx-start_with.hpp:75
Definition: rx-operators.hpp:69
auto AN
Definition: rx-finally.hpp:105
static auto member(AN &&...) -> typename Tag::template include_header< std::false_type >
Definition: rx-operators.hpp:50
typename std::decay< T >::type decay_t
Definition: rx-util.hpp:36
Definition: rx-operators.hpp:47
auto start_with(AN &&...an) -> operator_factory< start_with_tag, AN... >
Start with the supplied values, then concatenate this observable.
Definition: rx-start_with.hpp:53
linq_driver< iter_cursor< typename util::container_traits< TContainer >::iterator > > from(TContainer &c)
Definition: linq.hpp:556
typename std::enable_if< all_true_type< BN... >::value >::type enable_if_all_true_type_t
Definition: rx-util.hpp:114
auto first() -> operator_factory< first_tag >
For each item from this observable reduce it by sending only the first item.
Definition: rx-reduce.hpp:378
static auto member(Observable &&o, Value0 &&v0, ValueN &&...vn) -> decltype(member_overload< concat_tag >::member(std::declval< From >(), std::forward< Observable >(o)))
Definition: rx-start_with.hpp:68
Definition: rx-predef.hpp:177
For each item from this observable subscribe to one at a time, in the order received. For each item from all of the given observables deliver from the new observable that is returned.
Definition: rx-operators.hpp:388