22 #ifndef GEARS_STRING_TRANSFORMS_HPP
23 #define GEARS_STRING_TRANSFORMS_HPP
27 #include "../meta/alias.hpp"
49 template<
typename String>
53 return { str.substr(0, n) };
74 template<
typename String>
78 return { str.substr(str.size() - n) };
89 template<
typename String>
91 auto first = str.begin();
92 auto last = str.end();
93 while((first != last) && (first != --last)) {
95 swap(*first++, *last);
130 template<
typename String,
typename Cont>
132 auto first = cont.cbegin();
133 auto last = cont.cend();
134 std::basic_ostringstream<meta::ValueType<String>> ss;
138 while(first != last) {
139 ss << sep << *first++;
156 template<
typename String,
typename Cont,
typename UnaryPredicate>
158 auto first = cont.cbegin();
159 auto last = cont.cend();
160 std::basic_ostringstream<meta::ValueType<String>> ss;
163 while(!pred(*first)) ++first;
169 while(first != last) {
171 ss << sep << *first++;
216 template<
typename String,
typename OutIt>
217 inline OutIt
split(
const String& str,
const String& sep, OutIt it) {
218 size_t start = 0,
end = 0;
219 while((
end = str.find(sep, start)) != String::npos) {
220 *it++ = str.substr(start,
end - start);
221 start =
end + sep.length();
223 *it++ = str.substr(start);
229 #endif // GEARS_STRING_TRANSFORMS_HPP