From 1e565b2c06bf2a24f9a6e61a5518776f69c9ba12 Mon Sep 17 00:00:00 2001 From: Denis Blank Date: Wed, 10 Jun 2015 15:23:43 +0200 Subject: [PATCH] some workarrounds for clang... --- fluent++/Callback.h | 15 +++++++++++---- fluent++/Continuable.h | 23 +++++++++++++++++++++++ fluent++/WeakCallbackContainer.h | 5 +++-- 3 files changed, 37 insertions(+), 6 deletions(-) create mode 100644 fluent++/Continuable.h diff --git a/fluent++/Callback.h b/fluent++/Callback.h index 93fc9ad..20c7562 100644 --- a/fluent++/Callback.h +++ b/fluent++/Callback.h @@ -54,14 +54,19 @@ namespace detail template struct WeakProxyFactory { - static Callback CreateProxy(WeakCallback const& weak_callback) + static Callback CreateProxyFromWeak(WeakCallback const& weak_callback) { return [=](Args&&... args) { if (auto const callback = weak_callback.lock()) - (*callback)(args...); + (*callback)(args...); // FIXME: use std::forward }; } + + static Callback CreateProxyFromShared(SharedCallback const& shared_callback) + { + return CreateProxyFromWeak(WeakCallback(shared_callback)); + } }; } // detail @@ -87,14 +92,16 @@ template inline auto make_weak_wrapped_callback(WeakCallback const& weak_callback) -> Callback { - return detail::WeakProxyFactory::CreateProxy(weak_callback); + // Some workarounds for clang... + return detail::WeakProxyFactory::CreateProxyFromWeak(weak_callback); } template inline auto make_weak_wrapped_callback(SharedCallback const& shared_callback) -> Callback { - return detail::WeakProxyFactory::CreateProxy(WeakCallback(shared_callback)); + // Some workarounds for clang... + return detail::WeakProxyFactory::CreateProxyFromShared(shared_callback); } #endif /// _CALLBACK_H_ diff --git a/fluent++/Continuable.h b/fluent++/Continuable.h new file mode 100644 index 0000000..3a9b77a --- /dev/null +++ b/fluent++/Continuable.h @@ -0,0 +1,23 @@ +/* + * Copyright (C) 2008-2015 TrinityCore + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see . + */ + +#ifndef _CONTINUABLE_H_ +#define _CONTINUABLE_H_ + + + +#endif /// _CONTINUABLE_H_ diff --git a/fluent++/WeakCallbackContainer.h b/fluent++/WeakCallbackContainer.h index 287f76f..ee66731 100644 --- a/fluent++/WeakCallbackContainer.h +++ b/fluent++/WeakCallbackContainer.h @@ -54,8 +54,7 @@ class WeakCallbackContainer if (auto const callback = weak_callback.lock()) { // Invoke the original callback - // FIXME: std::forward(args...) causes errors when void - (*callback)(args...); + (*callback)(args...); // FIXME: use std::forward // Unregister the callback owner->InvalidateCallback(handle); @@ -82,6 +81,7 @@ public: return *this; } + /// Weak wraps the given callable. template auto Wrap(_CTy&& callback) -> callback_of_t<_CTy> @@ -99,6 +99,7 @@ public: return std::move(proxy); } + /// Calls ::Wrap on the given callable, template inline auto operator()(_CTy&& callback) -> decltype(Wrap(std::declval<_CTy>()))