From c61de194f49c47880f8a886c88dcf044f893861a Mon Sep 17 00:00:00 2001 From: Adrian Kummerländer Date: Thu, 10 Apr 2014 20:26:20 +0200 Subject: Added operator- member implementation and improved test cases * operator- takes a reference to a const std::string::const_iterator and as such enables determining the actual position of a codepoint within a string * ranged for loops in test cases now take the iterator value by rvalue reference instead of by value --- src/codepoint_iterator.cc | 5 +++++ src/codepoint_iterator.h | 2 ++ 2 files changed, 7 insertions(+) (limited to 'src') diff --git a/src/codepoint_iterator.cc b/src/codepoint_iterator.cc index b2f6d81..59cb23b 100644 --- a/src/codepoint_iterator.cc +++ b/src/codepoint_iterator.cc @@ -34,6 +34,11 @@ bool CodepointIterator::operator!=( return this->iterator_ != src; } +std::ptrdiff_t CodepointIterator::operator-( + const std::string::const_iterator& src) const { + return this->iterator_ - src; +} + char32_t CodepointIterator::operator*() { std::uint8_t currByte = *(this->iterator_); char32_t codePoint = 0; diff --git a/src/codepoint_iterator.h b/src/codepoint_iterator.h index b505587..d1806e5 100644 --- a/src/codepoint_iterator.h +++ b/src/codepoint_iterator.h @@ -22,6 +22,8 @@ class CodepointIterator : public std::iterator