From 08b68efc5e5d35a7b313c2a588850cfde4efd3f6 Mon Sep 17 00:00:00 2001 From: Naios Date: Sun, 14 Jun 2015 19:03:49 +0200 Subject: [PATCH] test --- fluent/Continuable.h | 45 ++++++++++++++++++++++++++++++-------------- 1 file changed, 31 insertions(+), 14 deletions(-) diff --git a/fluent/Continuable.h b/fluent/Continuable.h index 480bc03..425b205 100644 --- a/fluent/Continuable.h +++ b/fluent/Continuable.h @@ -39,7 +39,7 @@ namespace detail template class _ContinuableImpl; - /// Corrects void return types from functional types which should be Continuable> + /// Corrects void return types from functional types which should be Continuable> template struct convert_void_to_continuable; @@ -77,14 +77,16 @@ namespace detail } public: + // Empty for debugging + _ContinuableImpl() + : _released(false) { } + /// Deleted copy construct - template - _ContinuableImpl(_ContinuableImpl<_RState, _RCTy> const&) = delete; + _ContinuableImpl(_ContinuableImpl const&) = delete; /// Move construct - template - _ContinuableImpl(_ContinuableImpl<_RState, _RCTy>&& right) - : _released(right._released) + _ContinuableImpl(_ContinuableImpl&& right) + : _released(right._released), _callback_insert(std::move(right._callback_insert)) { right._released = true; } @@ -106,23 +108,38 @@ namespace detail /// Deleted copy assign template - _ContinuableImpl& operator= (_ContinuableImpl<_RState, _RCTy> const&) = delete; + _ContinuableImpl& operator= (_ContinuableImpl const&) = delete; /// Move construct assign - template - _ContinuableImpl& operator= (_ContinuableImpl<_RState, _RCTy>&& right) + _ContinuableImpl& operator= (_ContinuableImpl&& right) { _released = right._released; right._released = true; + _callback_insert = std::move(right._callback_insert); return *this; } - // TODO Accept only correct callbacks - template - _ContinuableImpl> then(_CTy&&) + template + struct unary_chainer; + + template + struct unary_chainer> { - // TODO Transmute the returned callback here. - return _ContinuableImpl>(std::move(*this)); + template + static auto chain(_CTy&& functional, _ContinuableImpl&& me) + -> typename convert_void_to_continuable<_NewRTy>::type + { + return _ContinuableImpl, Callback<_NewATy...>>(); + } + }; + + template + auto then(_CTy&& functional) + -> decltype(unary_chainer::type>:: + chain(std::declval<_CTy>())) + { + return unary_chainer>:: + chain(std::forward<_CTy>(functional), std::move(*this)); } /*