From 39fe8d073e3f58c3b5bea09aefb8315e6f86f817 Mon Sep 17 00:00:00 2001 From: Kirk Shoop Date: Tue, 27 Sep 2016 00:25:08 -0700 Subject: decouple zip operator from observable made changes to the operator implementation pattern. using zip as the first example. allows rx-lite.hpp to not include the operators and instead have the app explicitly include only the operators needed. allows all zip related logic to be only in the rx-zip.hpp. observable only has a forwarding function named zip and operators define zip_tag and its include_header member. improves docs by linking the observable and free operator methods to the single doc at file scope. operator_member_missing overloads allow static asserts to help usage. the include_header member of the zip_tag allows a static assert to ask for the zip file to be included when omitted in rx-lite mode --- Rx/v2/examples/doxygen/main.cpp | 9 +++++++++ Rx/v2/examples/doxygen/range.cpp | 7 +------ Rx/v2/examples/doxygen/zip.cpp | 2 +- 3 files changed, 11 insertions(+), 7 deletions(-) (limited to 'Rx/v2/examples') diff --git a/Rx/v2/examples/doxygen/main.cpp b/Rx/v2/examples/doxygen/main.cpp index 0c7c351..8a831f2 100644 --- a/Rx/v2/examples/doxygen/main.cpp +++ b/Rx/v2/examples/doxygen/main.cpp @@ -1,2 +1,11 @@ #define CATCH_CONFIG_MAIN #include "catch.hpp" + +#include +#include +#include +std::string get_pid() { + std::stringstream s; + s << std::this_thread::get_id(); + return s.str(); +} diff --git a/Rx/v2/examples/doxygen/range.cpp b/Rx/v2/examples/doxygen/range.cpp index 7b84d7f..69eecbd 100644 --- a/Rx/v2/examples/doxygen/range.cpp +++ b/Rx/v2/examples/doxygen/range.cpp @@ -13,12 +13,7 @@ SCENARIO("range sample"){ printf("//! [range sample]\n"); } -#include -std::string get_pid() { - std::stringstream s; - s << std::this_thread::get_id(); - return s.str(); -} +std::string get_pid(); SCENARIO("threaded range sample"){ printf("//! [threaded range sample]\n"); diff --git a/Rx/v2/examples/doxygen/zip.cpp b/Rx/v2/examples/doxygen/zip.cpp index 9085110..c5cd07b 100644 --- a/Rx/v2/examples/doxygen/zip.cpp +++ b/Rx/v2/examples/doxygen/zip.cpp @@ -51,7 +51,7 @@ SCENARIO("Selector zip sample"){ auto o1 = rxcpp::observable<>::interval(std::chrono::milliseconds(1)); auto o2 = rxcpp::observable<>::interval(std::chrono::milliseconds(2)); auto o3 = rxcpp::observable<>::interval(std::chrono::milliseconds(3)); - auto values = o1.zip( + auto values = o1 | rxcpp::operators::zip( [](int v1, int v2, int v3) { return 100 * v1 + 10 * v2 + v3; }, -- cgit v1.2.3