Move string split to misc

This commit is contained in:
Tomasz Sobczyk
2020-10-14 22:35:35 +02:00
committed by nodchip
parent 69ea3d30b2
commit 2398d34e87

View File

@@ -30,6 +30,7 @@
#include <utility>
#include <cmath>
#include <cctype>
#include <sstream>
#include "types.h"
@@ -273,6 +274,19 @@ namespace Algo {
for (uint64_t i = 0; i < size; ++i)
std::swap(buf[i], buf[prng.rand(size - i) + i]);
}
// split the string
inline std::vector<std::string> split(const std::string& input, char delimiter) {
std::istringstream stream(input);
std::string field;
std::vector<std::string> fields;
while (std::getline(stream, field, delimiter)) {
fields.push_back(field);
}
return fields;
}
}
// --------------------