Open aaangeletakis opened 3 years ago
Turns out you can get the position via a view
#include "ctre.hpp"
#include <iostream>
const char * input = "123,456,768";
//extern const char * input;
int main(void){
static constexpr ctll::fixed_string pat = "([0-9]+),?";
auto matches = ctre::range<pat>(input);
for (auto match: matches) {
auto view = match.to_view();
std::cout << view.data() - input << " [" << view << "]\n";
}
return 0;
}
The STL has a match_results::position() function that returns the position of the match in the string. https://www.cplusplus.com/reference/regex/match_results/position/
This could possibly be implemented via subtracting 2 pointers.
Example use
Compiler Explorer