Core/Algorithm: Fix Apply problems

This commit is contained in:
Lynix 2018-03-20 20:59:54 +01:00
parent ad82de2962
commit 9a8c807d18
2 changed files with 3 additions and 2 deletions

View File

@ -74,6 +74,7 @@ Nazara Engine:
- Fixed Platform module not being classified as client-only
- ⚠️ Renamed Bitset::Read to Bitset::Write
- ⚠️ Added a type tag parameter to Serialize and Unserialize functions, to prevent implicit conversions with overloads
- Fixed Apply functions with complex return types
Nazara Development Kit:
- Added ImageWidget (#139)

View File

@ -21,13 +21,13 @@ namespace Nz
{
// http://www.cppsamples.com/common-tasks/apply-tuple-to-function.html
template<typename F, typename Tuple, size_t... S>
decltype(auto) ApplyImplFunc(F&& fn, Tuple&& t, std::index_sequence<S...>)
auto ApplyImplFunc(F&& fn, Tuple&& t, std::index_sequence<S...>)
{
return std::forward<F>(fn)(std::get<S>(std::forward<Tuple>(t))...);
}
template<typename O, typename F, typename Tuple, size_t... S>
decltype(auto) ApplyImplMethod(O& object, F&& fn, Tuple&& t, std::index_sequence<S...>)
auto ApplyImplMethod(O& object, F&& fn, Tuple&& t, std::index_sequence<S...>)
{
return (object .* std::forward<F>(fn))(std::get<S>(std::forward<Tuple>(t))...);
}