From bf52141e946495c9785d9b5e1ec254729d1e462f Mon Sep 17 00:00:00 2001 From: Denis Blank Date: Tue, 21 Jul 2015 17:53:37 +0200 Subject: [PATCH] Fix some warnings reported by /W4 --- include/Continuable.h | 2 +- include/WeakCallbackContainer.h | 22 +++++++++++----------- include/functional_unwrap.hpp | 5 +++++ 3 files changed, 17 insertions(+), 12 deletions(-) diff --git a/include/Continuable.h b/include/Continuable.h index c3600e7..b517d28 100644 --- a/include/Continuable.h +++ b/include/Continuable.h @@ -584,7 +584,7 @@ namespace detail } // Do nothing when trying to store empty packs... - inline static void store(std::tuple<_RTy...>& result) + inline static void store(std::tuple<_RTy...>& /*result*/) { } diff --git a/include/WeakCallbackContainer.h b/include/WeakCallbackContainer.h index 3794052..4757939 100644 --- a/include/WeakCallbackContainer.h +++ b/include/WeakCallbackContainer.h @@ -31,9 +31,9 @@ class WeakCallbackContainer typedef std::size_t handle_t; - std::size_t handle; + std::size_t _handle; - std::unordered_map container; + std::unordered_map _container; template struct ProxyFactory; @@ -44,7 +44,7 @@ class WeakCallbackContainer // Creates a weak proxy callback which prevents invoking to an invalid context. // Removes itself from the owner with the given handler. static callback_of_t<_CTy> CreateProxy(std::weak_ptr const& weak_owner, - std::size_t const handle, weak_callback_of_t<_CTy> const& weak_callback) + std::size_t const _handle, weak_callback_of_t<_CTy> const& weak_callback) { return [=](Args&&... args) { @@ -57,7 +57,7 @@ class WeakCallbackContainer (*callback)(std::forward(args)...); // Unregister the callback - owner->InvalidateCallback(handle); + owner->InvalidateCallback(_handle); } }; } @@ -65,7 +65,7 @@ class WeakCallbackContainer public: WeakCallbackContainer() - : self_reference(this, [](decltype(this)) { }), handle(0L) { } + : self_reference(this, [](decltype(this)) { }), _handle(0L) { } ~WeakCallbackContainer() = default; @@ -77,7 +77,7 @@ public: WeakCallbackContainer& Clear() { - container.clear(); + _container.clear(); return *this; } @@ -90,12 +90,12 @@ public: shared_callback_of_t<_CTy> shared_callback = make_shared_callback(std::forward<_CTy>(callback)); // Create a weak proxy callback which removes the callback on execute - auto const this_handle = handle++; + auto const this_handle = _handle++; callback_of_t<_CTy> proxy = ProxyFactory<_CTy, ::fu::argument_type_of_t<_CTy>>:: CreateProxy(self_reference, this_handle, shared_callback); - container.insert(std::make_pair(this_handle, boost::any(std::move(shared_callback)))); + _container.insert(std::make_pair(this_handle, boost::any(std::move(shared_callback)))); return std::move(proxy); } @@ -109,15 +109,15 @@ public: boost::optional GetLastCallbackHandle() const { - if (handle == 0L) + if (_handle == 0L) return boost::none; else - return boost::make_optional(handle); + return boost::make_optional(_handle); } WeakCallbackContainer& InvalidateCallback(handle_t const handle) { - container.erase(handle); + _container.erase(handle); return *this; } }; diff --git a/include/functional_unwrap.hpp b/include/functional_unwrap.hpp index e2573be..6825277 100644 --- a/include/functional_unwrap.hpp +++ b/include/functional_unwrap.hpp @@ -220,10 +220,15 @@ namespace fu template struct invoker> { + template + inline static void silencer(_TTy&&) { } + template inline static auto invoke(_FTy&& functional, _TTy&& tuple) -> return_type_of_t::type> { + // Silences warnings about unreferenced formal parameter when pack is empty. + silencer(tuple); return std::forward<_FTy>(functional)(std::get(std::forward<_TTy>(tuple))...); } };