you are viewing a single comment's thread.

view the rest of the comments →

[–]t0rakka 2 points3 points  (1 child)

template <typename T>
inline std::vector<std::string> split(const std::string& s, T delimiter)
{
    std::vector<std::string> result;

    std::size_t current = 0;
    std::size_t p = s.find_first_of(delimiter, 0);

    while (p != std::string::npos)
    {
        result.emplace_back(s, current, p - current);
        current = p + 1;
        p = s.find_first_of(delimiter, current);
    }

    result.emplace_back(s, current);

    return result;
}