aboutsummaryrefslogtreecommitdiff
path: root/src/codepoint_iterator.cc
diff options
context:
space:
mode:
authorAdrian Kummerländer2014-04-10 20:26:20 +0200
committerAdrian Kummerländer2014-04-10 20:26:20 +0200
commitc61de194f49c47880f8a886c88dcf044f893861a (patch)
tree18bf3086d007d4098fddcbbe62b0469c548a944e /src/codepoint_iterator.cc
parent572af7499d088a239d37e9dc09e5e7ac45c13d29 (diff)
downloadCodepointIterator-c61de194f49c47880f8a886c88dcf044f893861a.tar
CodepointIterator-c61de194f49c47880f8a886c88dcf044f893861a.tar.gz
CodepointIterator-c61de194f49c47880f8a886c88dcf044f893861a.tar.bz2
CodepointIterator-c61de194f49c47880f8a886c88dcf044f893861a.tar.lz
CodepointIterator-c61de194f49c47880f8a886c88dcf044f893861a.tar.xz
CodepointIterator-c61de194f49c47880f8a886c88dcf044f893861a.tar.zst
CodepointIterator-c61de194f49c47880f8a886c88dcf044f893861a.zip
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
Diffstat (limited to 'src/codepoint_iterator.cc')
-rw-r--r--src/codepoint_iterator.cc5
1 files changed, 5 insertions, 0 deletions
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;