diff options
author | Eike Ziller <[email protected]> | 2017-12-06 17:25:24 +0100 |
---|---|---|
committer | Eike Ziller <[email protected]> | 2017-12-07 09:55:49 +0000 |
commit | 6d05ba7bfcd6f0ae1e1af100cd4aab1cdc0c3a8c (patch) | |
tree | 92986cb9d6e91b6e0cbac4ce6135ccc57a1f4234 /src/libs | |
parent | fb4f7e74205aeda6b5289001c35b018cf9750fc9 (diff) |
Algorithm: Fix compilation with Xcode 7.2.1
Change-Id: I4413841adc00156a4c8877c00ba6929262ae8e8f
Reviewed-by: Tobias Hunger <[email protected]>
Diffstat (limited to 'src/libs')
-rw-r--r-- | src/libs/utils/algorithm.h | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/src/libs/utils/algorithm.h b/src/libs/utils/algorithm.h index c0fb62b645f..7c0b73d2028 100644 --- a/src/libs/utils/algorithm.h +++ b/src/libs/utils/algorithm.h @@ -333,7 +333,7 @@ inserter(QSet<X> &container) // different container types for input and output, e.g. transforming a QList into a QSet // function: -template<template<typename, typename...> class C, // result container type +template<template<typename> class C, // result container type template<typename...> class SC, // input container type typename F, // function type typename... SCArgs, // Arguments to SC @@ -348,6 +348,22 @@ decltype(auto) transform(const SC<SCArgs...> &container, F function) return result; } +template<template<typename, typename> class C, // result container type + template<typename...> class SC, // input container type + typename F, // function type + typename... SCArgs, // Arguments to SC + typename Value = typename SC<SCArgs...>::value_type, + typename Result = std::decay_t<std::result_of_t<F(Value)>>, + typename ResultContainer = C<Result, std::allocator<Result>>> +Q_REQUIRED_RESULT +decltype(auto) transform(const SC<SCArgs...> &container, F function) +{ + ResultContainer result; + result.reserve(container.size()); + std::transform(std::begin(container), std::end(container), inserter(result), function); + return result; +} + // member function: template<template<typename...> class C, // result container type template<typename...> class SC, // input container type |