eliaskosunen/scnlib

Add support for fixed length arrays output variables

matbech opened this issue · 1 comments

I was expecting something like this to work:

char bla[8];
scn::scan("input", "{}", bla);

However I'm getting this compiler error:
scnlib\include\scn\detail\args.h(118,53): error C2079: 's' uses undefined struct 'scn::v0::scanner<char,T,void>'

I'm aware that I can use a string_view output argument as a workaround:

string_view bla;
scn::scan("input", "{}", bla);

Now, scn::span also provides that support.

char buffer[8] = {0};
auto span = scn::make_span(buffer, 8);
auto result = scn::scan("input", "{}", span);
// buffer == "input"
// span.begin() points to buffer

// Same with string_view
std::string_view str;
result = scn::scan("input", "{}", str);
// str == "input"
// str.begin() points to string literal "input"

Because of the way raw arrays work and decay in C++, providing support for them specifically is not really feasible.