diff options
| author | Neil <nyamatongwe@gmail.com> | 2021-11-24 09:21:38 +1100 | 
|---|---|---|
| committer | Neil <nyamatongwe@gmail.com> | 2021-11-24 09:21:38 +1100 | 
| commit | 58f9140a90c7746d3f526ad71791d80fb0597a68 (patch) | |
| tree | fd32931a5ce151af906d31fbd25251d97bec7425 /src/Document.cxx | |
| parent | db88fdbca47826624fd95c911a55a97266fd03c2 (diff) | |
| download | scintilla-mirror-58f9140a90c7746d3f526ad71791d80fb0597a68.tar.gz | |
For iterators, make constructors explicit, remove operators that are defaulted
correctly and use 'using' in preference to 'typedef'.
Diffstat (limited to 'src/Document.cxx')
| -rw-r--r-- | src/Document.cxx | 89 | 
1 files changed, 17 insertions, 72 deletions
diff --git a/src/Document.cxx b/src/Document.cxx index 511d8ca3b..3d6e48a98 100644 --- a/src/Document.cxx +++ b/src/Document.cxx @@ -2871,35 +2871,18 @@ public:  class ByteIterator {  public: -	typedef std::bidirectional_iterator_tag iterator_category; -	typedef char value_type; -	typedef ptrdiff_t difference_type; -	typedef char* pointer; -	typedef char& reference; +	using iterator_category = std::bidirectional_iterator_tag; +	using value_type = char; +	using difference_type = ptrdiff_t; +	using pointer = char*; +	using reference = char&;  	const Document *doc;  	Sci::Position position; -	ByteIterator(const Document *doc_=nullptr, Sci::Position position_=0) noexcept : +	explicit ByteIterator(const Document *doc_=nullptr, Sci::Position position_=0) noexcept :  		doc(doc_), position(position_) {  	} -	ByteIterator(const ByteIterator &other) noexcept { -		doc = other.doc; -		position = other.position; -	} -	ByteIterator(ByteIterator &&other) noexcept { -		doc = other.doc; -		position = other.position; -	} -	ByteIterator &operator=(const ByteIterator &other) noexcept { -		if (this != &other) { -			doc = other.doc; -			position = other.position; -		} -		return *this; -	} -	ByteIterator &operator=(ByteIterator &&) noexcept = default; -	~ByteIterator() = default;  	char operator*() const noexcept {  		return doc->CharAt(position);  	} @@ -2956,11 +2939,11 @@ class UTF8Iterator {  	size_t lenCharacters;  	wchar_t buffered[2];  public: -	typedef std::bidirectional_iterator_tag iterator_category; -	typedef wchar_t value_type; -	typedef ptrdiff_t difference_type; -	typedef wchar_t* pointer; -	typedef wchar_t& reference; +	using iterator_category = std::bidirectional_iterator_tag; +	using value_type = wchar_t; +	using difference_type = ptrdiff_t; +	using pointer = wchar_t*; +	using reference = wchar_t&;  	explicit UTF8Iterator(const Document *doc_=nullptr, Sci::Position position_=0) noexcept :  		doc(doc_), position(position_), characterIndex(0), lenBytes(0), lenCharacters(0), buffered{} { @@ -2970,30 +2953,6 @@ public:  			ReadCharacter();  		}  	} -	UTF8Iterator(const UTF8Iterator &other) noexcept : buffered{} { -		doc = other.doc; -		position = other.position; -		characterIndex = other.characterIndex; -		lenBytes = other.lenBytes; -		lenCharacters = other.lenCharacters; -		buffered[0] = other.buffered[0]; -		buffered[1] = other.buffered[1]; -	} -	UTF8Iterator(UTF8Iterator &&other) noexcept = default; -	UTF8Iterator &operator=(const UTF8Iterator &other) noexcept { -		if (this != &other) { -			doc = other.doc; -			position = other.position; -			characterIndex = other.characterIndex; -			lenBytes = other.lenBytes; -			lenCharacters = other.lenCharacters; -			buffered[0] = other.buffered[0]; -			buffered[1] = other.buffered[1]; -		} -		return *this; -	} -	UTF8Iterator &operator=(UTF8Iterator &&) noexcept = default; -	~UTF8Iterator() = default;  	wchar_t operator*() const noexcept {  		assert(lenCharacters != 0);  		return buffered[characterIndex]; @@ -3071,29 +3030,15 @@ class UTF8Iterator {  	const Document *doc;  	Sci::Position position;  public: -	typedef std::bidirectional_iterator_tag iterator_category; -	typedef wchar_t value_type; -	typedef ptrdiff_t difference_type; -	typedef wchar_t* pointer; -	typedef wchar_t& reference; +	using iterator_category = std::bidirectional_iterator_tag; +	using value_type = wchar_t; +	using difference_type = ptrdiff_t; +	using pointer = wchar_t*; +	using reference = wchar_t&; -	UTF8Iterator(const Document *doc_=nullptr, Sci::Position position_=0) noexcept : +	explicit UTF8Iterator(const Document *doc_=nullptr, Sci::Position position_=0) noexcept :  		doc(doc_), position(position_) {  	} -	UTF8Iterator(const UTF8Iterator &other) noexcept { -		doc = other.doc; -		position = other.position; -	} -	UTF8Iterator(UTF8Iterator &&other) noexcept = default; -	UTF8Iterator &operator=(const UTF8Iterator &other) noexcept { -		if (this != &other) { -			doc = other.doc; -			position = other.position; -		} -		return *this; -	} -	UTF8Iterator &operator=(UTF8Iterator &&) noexcept = default; -	~UTF8Iterator() = default;  	wchar_t operator*() const noexcept {  		const Document::CharacterExtracted charExtracted = doc->ExtractCharacter(position);  		return charExtracted.character;  | 
