Skip to content

Instantly share code, notes, and snippets.

@tshev
Last active November 17, 2020 11:28
Show Gist options
  • Save tshev/a11e4efeddc67d0574130a0ca0094f1d to your computer and use it in GitHub Desktop.
Save tshev/a11e4efeddc67d0574130a0ca0094f1d to your computer and use it in GitHub Desktop.
#include <sgl/sgl.h>
#include <iostream>
#include <vector>
#include <string>
int main() {
sgl::v1::mmap<char> text("text.txt");
char* text_first = std::begin(text);
char* text_last = std::end(text);
size_t lines_count = std::count(text_first, text_last, '\n');
std::vector<std::string_view> strings(lines_count);
sgl::v1::transform_splits(text_first, text_last, '\n', std::begin(strings), sgl::v1::f::construct<std::string_view>());
std::sort(std::begin(strings), std::end(strings));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment