#include "trim.hpp" namespace wavefront { std::string_view trim(const std::string_view &source) { auto start = source.data(); // size is the size of buffer, data() + size() is the first available byte after the string. auto end = source.data() + source.size() - 1; while (start < end && std::isspace(*start)) { ++start; } while (start < end && (std::isspace(*end) || *end == 0)) { --end; } return std::string_view(start, end - start + 1); } }