forked from qt-creator/qt-creator
Algorithm: Fix compilation with Xcode 7.2.1
Change-Id: I4413841adc00156a4c8877c00ba6929262ae8e8f Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
This commit is contained in:
@@ -333,7 +333,7 @@ inserter(QSet<X> &container)
|
|||||||
// different container types for input and output, e.g. transforming a QList into a QSet
|
// different container types for input and output, e.g. transforming a QList into a QSet
|
||||||
|
|
||||||
// function:
|
// 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
|
template<typename...> class SC, // input container type
|
||||||
typename F, // function type
|
typename F, // function type
|
||||||
typename... SCArgs, // Arguments to SC
|
typename... SCArgs, // Arguments to SC
|
||||||
@@ -348,6 +348,22 @@ decltype(auto) transform(const SC<SCArgs...> &container, F function)
|
|||||||
return result;
|
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:
|
// member function:
|
||||||
template<template<typename...> class C, // result container type
|
template<template<typename...> class C, // result container type
|
||||||
template<typename...> class SC, // input container type
|
template<typename...> class SC, // input container type
|
||||||
|
Reference in New Issue
Block a user