QXmpp  Version: 1.7.1
Algorithms.h
1 // SPDX-FileCopyrightText: 2024 Linus Jahn <lnj@kaidan.im>
2 //
3 // SPDX-License-Identifier: LGPL-2.1-or-later
4 
5 #ifndef ALGORITHMS_H
6 #define ALGORITHMS_H
7 
8 #include <algorithm>
9 
10 namespace QXmpp::Private {
11 
12 template<typename OutputVector, typename InputVector, typename Converter>
13 auto transform(InputVector &input, Converter convert)
14 {
15  OutputVector output;
16  output.reserve(input.size());
17  std::transform(input.begin(), input.end(), std::back_inserter(output), std::forward<Converter>(convert));
18  return output;
19 }
20 
21 } // namespace QXmpp::Private
22 
23 #endif // ALGORITHMS_H