From 88fea9943e0d1bdf8035596d1c1a7f7a5a6054f2 Mon Sep 17 00:00:00 2001 From: Denis Blank Date: Thu, 11 Jun 2015 03:01:55 +0200 Subject: [PATCH] cleanups --- fluent/Callback.h | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/fluent/Callback.h b/fluent/Callback.h index 34b0789..27f2ba8 100644 --- a/fluent/Callback.h +++ b/fluent/Callback.h @@ -25,12 +25,15 @@ #include "functional_unwrap.hpp" +/// A general purpose Callback type (Callable/Invokeable) template using Callback = std::function; +/// A Callback wrapped in a std::shared_ptr template using SharedCallback = std::shared_ptr>; +/// A Callback wrapped in a std::weak_ptr template using WeakCallback = std::weak_ptr>; @@ -80,18 +83,22 @@ namespace detail } // detail +/// Unwraps the callback type of the given functional object. template using callback_of_t = typename detail::unwrap_callback_t<_CTy>::CallbackType; +/// Unwraps the shared callback type of the given functional object. template using shared_callback_of_t = typename detail::unwrap_callback_t<_CTy>::SharedCallbackType; +/// Unwraps the weak callback type of the given functional object. template using weak_callback_of_t = typename detail::unwrap_callback_t<_CTy>::WeakCallbackType; +/// Creates a callback wrapped in a std::shared_ptr. template -inline shared_callback_of_t<_CTy> - make_shared_callback(_CTy&& callback) +inline auto make_shared_callback(_CTy&& callback) + -> shared_callback_of_t<_CTy> { return std::make_shared> (std::forward>(callback)); @@ -101,8 +108,8 @@ inline shared_callback_of_t<_CTy> /// If the given managed callback expires the callback is not invoked anymore. template inline auto make_weak_wrapped_callback(_CTy const& callback) - -> decltype(detail::WeakProxyFactory<_CTy>::CreateProxy(callback)) -{ + -> decltype(detail::WeakProxyFactory<_CTy>::CreateProxy(std::declval<_CTy>())) +{ return detail::WeakProxyFactory<_CTy>::CreateProxy(callback); }