Fix some warnings reported by /W4

This commit is contained in:
Naios 2015-07-21 17:53:37 +02:00
parent a00d7981e5
commit 245f336114
3 changed files with 17 additions and 12 deletions

View File

@ -584,7 +584,7 @@ namespace detail
} }
// Do nothing when trying to store empty packs... // Do nothing when trying to store empty packs...
inline static void store(std::tuple<_RTy...>& result) inline static void store(std::tuple<_RTy...>& /*result*/)
{ {
} }

View File

@ -31,9 +31,9 @@ class WeakCallbackContainer
typedef std::size_t handle_t; typedef std::size_t handle_t;
std::size_t handle; std::size_t _handle;
std::unordered_map<decltype(handle), boost::any> container; std::unordered_map<decltype(_handle), boost::any> _container;
template<typename _CTy, typename... Args> template<typename _CTy, typename... Args>
struct ProxyFactory; struct ProxyFactory;
@ -44,7 +44,7 @@ class WeakCallbackContainer
// Creates a weak proxy callback which prevents invoking to an invalid context. // Creates a weak proxy callback which prevents invoking to an invalid context.
// Removes itself from the owner with the given handler. // Removes itself from the owner with the given handler.
static callback_of_t<_CTy> CreateProxy(std::weak_ptr<WeakCallbackContainer> const& weak_owner, static callback_of_t<_CTy> CreateProxy(std::weak_ptr<WeakCallbackContainer> 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) return [=](Args&&... args)
{ {
@ -57,7 +57,7 @@ class WeakCallbackContainer
(*callback)(std::forward<Args>(args)...); (*callback)(std::forward<Args>(args)...);
// Unregister the callback // Unregister the callback
owner->InvalidateCallback(handle); owner->InvalidateCallback(_handle);
} }
}; };
} }
@ -65,7 +65,7 @@ class WeakCallbackContainer
public: public:
WeakCallbackContainer() WeakCallbackContainer()
: self_reference(this, [](decltype(this)) { }), handle(0L) { } : self_reference(this, [](decltype(this)) { }), _handle(0L) { }
~WeakCallbackContainer() = default; ~WeakCallbackContainer() = default;
@ -77,7 +77,7 @@ public:
WeakCallbackContainer& Clear() WeakCallbackContainer& Clear()
{ {
container.clear(); _container.clear();
return *this; return *this;
} }
@ -90,12 +90,12 @@ public:
shared_callback_of_t<_CTy> shared_callback = make_shared_callback(std::forward<_CTy>(callback)); 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 // 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 = callback_of_t<_CTy> proxy =
ProxyFactory<_CTy, ::fu::argument_type_of_t<_CTy>>:: ProxyFactory<_CTy, ::fu::argument_type_of_t<_CTy>>::
CreateProxy(self_reference, this_handle, shared_callback); 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); return std::move(proxy);
} }
@ -109,15 +109,15 @@ public:
boost::optional<handle_t> GetLastCallbackHandle() const boost::optional<handle_t> GetLastCallbackHandle() const
{ {
if (handle == 0L) if (_handle == 0L)
return boost::none; return boost::none;
else else
return boost::make_optional(handle); return boost::make_optional(_handle);
} }
WeakCallbackContainer& InvalidateCallback(handle_t const handle) WeakCallbackContainer& InvalidateCallback(handle_t const handle)
{ {
container.erase(handle); _container.erase(handle);
return *this; return *this;
} }
}; };

View File

@ -220,10 +220,15 @@ namespace fu
template<std::size_t... Sequence> template<std::size_t... Sequence>
struct invoker<sequence<Sequence...>> struct invoker<sequence<Sequence...>>
{ {
template<typename _TTy>
inline static void silencer(_TTy&&) { }
template<typename _FTy, typename _TTy> template<typename _FTy, typename _TTy>
inline static auto invoke(_FTy&& functional, _TTy&& tuple) inline static auto invoke(_FTy&& functional, _TTy&& tuple)
-> return_type_of_t<typename std::decay<_FTy>::type> -> return_type_of_t<typename std::decay<_FTy>::type>
{ {
// Silences warnings about unreferenced formal parameter when pack is empty.
silencer(tuple);
return std::forward<_FTy>(functional)(std::get<Sequence>(std::forward<_TTy>(tuple))...); return std::forward<_FTy>(functional)(std::get<Sequence>(std::forward<_TTy>(tuple))...);
} }
}; };