constexpr std::tuple<int,char,int,char> t1 = parse("1a2b");
constexpr std::tuple<int,int,int,char> t2 = parse("123a");
constexpr std::tuple<char,int> t3 = parse("a2");
Would something like this be possible?
I am not totally fluent with TMP but I started with the following
template<std::size_t N,typename ...Args> constexpr
std::tuple<Args...> parse(const char* s[N]){
constexpr char c = s[0];
constexpr char* new_s[N-1] = "";
for (int i = 1; i < N; i++) {
new_s[i] = s[i];
}
//my own constexpr isdigit
if(!isdigit(c)){
return parse(new_s,c);
}
else if(isdigit(c)){
return parse(new_s,static_cast<int>(c));
}
throw std::invalid_argument("");
}
...
I wanted to do this recursively and accumulate the tuple but I quickly realized that every time I would pass in the new tuple the type would change.