I have only found examples of regex_iterators being intialised as
regex_iterator::<string::iterator>
If I have a class which contains a sequence of characters, such as:
class fooString {
private:
deque<bar> data;
// ... other functionality ...
}
Where bar is a class or struct that is compatible with std::to_string
How would I make fooString and bar compatible with regex so that I could call
fooString myFoo = ...
regex e( /* some regex notation */);
regex_iterator::<fooString::iterator> regIt(myFoo.begin(), myFoo.end(), e);
...and be able to iterate over it as I would with a string?
I tried the following experiement:
std::deque<int> testDeque { 4, 5, 5, 5, 6, 7 };
std::regex e("5{1,3}");
std::regex_iterator<std::deque<int>::iterator>
regIt(testDeque.begin(), testDeque.end(), e);
And get the compilation error
1>C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\regex(2271): error C2027: use of undefined type 'std::regex_traits<_Elem>'
with
[
_Elem=int
]
So I don't think the bidirectional iterator is enough since deque complies with that, I think the 'bar' object needs to be compatible. But I'm really not sure.
std::regex_iteratorreference, the iterator needs to be a bidirectional iterator. So if your iterator fulfills the requirements of a bidirectional iterator, you're good to go.