Maipa's Standard Library Extension 1.5.6
mstd
Loading...
Searching...
No Matches
strconcat.hpp
1/*
2 * mstd - Maipa's Standard Library
3 *
4 * Licensed under the BSD 3-Clause License with Attribution Requirement.
5 * See the LICENSE file for details: https://github.com/MAIPA01/mstd/blob/main/LICENSE
6 *
7 * Copyright (c) 2025, Patryk Antosik (MAIPA01)
8 */
9
10#pragma once
11#ifndef _MSTD_STRCONCAT_HPP_
12 #define _MSTD_STRCONCAT_HPP_
13
14 #include <mstd/config.hpp>
15
17_MSTD_WARNING("this is only available for c++17 and greater!");
18 #else
19
20 #include <mstd/string_types.hpp>
21
22namespace mstd {
23 template<class... Strings>
24 inline std::string& concat_to(std::string& out, Strings&&... strs) {
25 out.reserve(out.size() + (utils::string_size(strs) + ...));
26 (out += ... += strs);
27 return out;
28 }
29
30 template<class... Strings>
31 inline std::string concat(Strings&&... strs) {
32 std::string str;
33 return concat_to(str, std::forward<Strings>(strs)...);
34 }
35} // namespace mstd
36
37 #endif
38#endif
#define _MSTD_HAS_CXX17
Definition config.hpp:45
Definition arithmetic_types.hpp:23
std::string & concat_to(std::string &out, Strings &&... strs)
Definition strconcat.hpp:24
std::string concat(Strings &&... strs)
Definition strconcat.hpp:31