/** * Copyright 2015-2016 Denis Blank * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include #include #include namespace detail { template struct Identity { }; template struct IdentityInheritenceWrapper : Identity, IdentityInheritenceWrapper { }; enum class NamedParameterId { NAMED_PARAMATER_CALLBACK, NAMED_PARAMATER_REJECTOR }; template struct NamedParameter : std::integral_constant, std::common_type { }; template using GetNamedParameterOrDefault = void; template class ContinuableBase; template struct ReturnTypeToContinuableConverter; template struct template class ContinuableBase, typename CallbackType> { CallbackType callback_; public: explicit ContinuableBase(CallbackType&& callback) : callback_(std::move(callback)) { } template auto then(C&& continuation) { // The type the callback will evaluate to using EvaluatedTo = decltype(std::declval()(std::declval()...)); return EvaluatedTo{ }; } }; } // namespace detail using namespace detail; template using Continuable = detail::ContinuableBase>; template struct Callback { void operator() (Args... ) { } }; template auto make_continuable(Args&&...) { return Continuable<> { }; } auto http_request(std::string url) { return make_continuable([url](auto&& callback) { callback("
hi
"); }); } void testNextGen() { using t = GetNamedParameterOrDefault< NamedParameterId::NAMED_PARAMATER_CALLBACK, Identity<>, void, int, NamedParameter, float >; http_request("github.com") .then([](std::string content) { return }) .then([] { }); }