diff --git a/CMakeLists.txt b/CMakeLists.txt index 23834e1..e3ccb8e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -57,7 +57,7 @@ add_library(continue STATIC ${LIB_SOURCES}) include_directories(include dep/concurrentqueue) -set(TEST_SOURCES test.cpp) +set(TEST_SOURCES test.cpp mockup.cpp) add_executable(continue_test ${TEST_SOURCES}) diff --git a/mockup.cpp b/mockup.cpp new file mode 100644 index 0000000..547f8fc --- /dev/null +++ b/mockup.cpp @@ -0,0 +1,67 @@ + +#include +#include + +template +struct Continuable; + +template +Continuable<> make_continuable(Args&&...) +{ + return Continuable<>(); +} + +template +struct Continuable +{ + template + Continuable then(Args&&...) + { + return Continuable(); + } + + template + Continuable all(Args&&...) + { + return Continuable(); + } +}; + +template +Continuable<> operator&& (Continuable&&, Continuable&&) +{ + return Continuable<>(); +} + +template +Continuable<> operator|| (Continuable&&, Continuable&&) +{ + return Continuable<>(); +} + +Continuable<> http_request(std::string const& /*URL*/) +{ + return make_continuable([=](std::function&& callback) + { + // Do request... + + callback("some HTTP content"); + }); +} + +void test_mockup() +{ + Continuable<> c1 = make_continuable([] + { + }); + + Continuable<> c2 = make_continuable([] + { + }); + + Continuable<> c3 = make_continuable([] + { + }); + + Continuable<> c11 = (std::move(c1) && std::move(c2)) || std::move(c3); +} diff --git a/test.cpp b/test.cpp index f6d7347..bf9c9d8 100644 --- a/test.cpp +++ b/test.cpp @@ -303,8 +303,12 @@ public: }; */ +void test_mockup(); + int main(int /*argc*/, char** /*argv*/) { + test_mockup(); + // CopyMoveTracer tracer; /*