/** Copyright(c) 2015 - 2017 Denis Blank Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and / or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions : The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. **/ #ifndef TEST_CONTINUABLE_HPP__ #define TEST_CONTINUABLE_HPP__ #include #include "continuable/continuable-base.hpp" #include "continuable/continuable-testing.hpp" #include "continuable/continuable.hpp" #include "gtest/gtest.h" template class continuation_provider : public ::testing::Test, public Provider { public: auto supply() { return this->makeVoid([](auto&& callback) mutable { // ... std::forward(callback)(); }); }; template auto supply(Args&&... args) { return this->template make...>([values = std::make_tuple( std::forward( args)...)]( auto&& callback) mutable { cti::detail::util::unpack(std::move(values), [&](auto&&... passed) { // ... std::forward(callback)( std::forward(passed)...); }); }); } }; inline auto empty_caller() { return [](auto&& callback) { // ... std::forward(callback)(); }; } struct provide_copyable { template auto makeVoid(T&& callback) { return make(std::forward(callback)); } template auto make(T&& callback) { return cti::make_continuable(std::forward(callback)); } }; struct provide_unique { template auto makeVoid(T&& callback) { return make(std::forward(callback)); } template auto make(T&& callback) { return cti::make_continuable([ callback = std::forward(callback), guard = std::make_unique(0) ](auto&&... args) mutable { (void)(*guard); return std::move(callback)(std::forward(args)...); }); } }; struct provide_copyable_erasure { template auto makeVoid(T&& callback) { return make(std::forward(callback)); } template cti::continuable make(T&& callback) { return cti::make_continuable(std::forward(callback)); } }; struct provide_unique_erasure { template auto makeVoid(T&& callback) { return make(std::forward(callback)); } template cti::unique_continuable make(T&& callback) { return cti::make_continuable(std::forward(callback)); } }; /* template struct provide_continuation_or_left { Left left_; Right right_; template auto makeVoid(T&& callback) { return left_.template make(std::forward(callback)) || right_.template make(empty_caller()); } template auto make(T&& callback) { return left_.template make(std::forward(callback)) || right_.template make(empty_caller()); } }; */ template struct type_chainer { template auto add() { return type_chainer{}; } template