Debian Codegraph @

src/mpt/format/join.hpp

raw
1 /* SPDX-License-Identifier: BSL-1.0 OR BSD-3-Clause */
2
3 #ifndef MPT_FORMAT_JOIN_HPP
4 #define MPT_FORMAT_JOIN_HPP
5
6
7
8 #include "mpt/base/namespace.hpp"
9 #include "mpt/format/simple.hpp"
10 #include "mpt/string/utility.hpp"
11
12 #include <vector>
13
14 #include <cstddef>
15
16
17
18 namespace mpt {
19 inline namespace MPT_INLINE_NS {
20
21
22
23 template <typename Tstring, typename T>
24 Tstring join_format(const std::vector<T> & vals, const Tstring & sep = Tstring(1, char_constants<typename Tstring::value_type>::comma)) {
25 Tstring str;
26 for (std::size_t i = 0; i < vals.size(); ++i) {
27 if (i > 0) {
28 str += sep;
29 }
30 str += mpt::format<Tstring>::val(vals[i]);
31 }
32 return str;
33 }
34
35
36
37 } // namespace MPT_INLINE_NS
38 } // namespace mpt
39
40
41
42 #endif // MPT_FORMAT_JOIN_HPP