From 49e49d124635f1f08ca0fc8c68b794f0ab33d15a Mon Sep 17 00:00:00 2001 From: Tomasz Sowa Date: Wed, 17 Feb 2021 16:53:19 +0100 Subject: [PATCH] fixed: operator==() and operator!=() in iterators in MemBuffer<> template did not have 'const' modifier and there was an error when compiling with clang with -std=c++20 flag /usr/home/tomek/roboczy/prog/web.ttmath.org/../pikotools/textstream/textstream.h:225:11: fatal error: use of overloaded operator '!=' is ambiguous (with operand types 'PT::TextStreamBase::const_iterator' (aka 'PT::MemBuffer::const_iterator') and 'PT::TextStreamBase::const_iterator') for( ; i != end() ; ++i) ~ ^ ~~~~~ /usr/home/tomek/roboczy/prog/web.ttmath.org/../morm/src/finderhelper.h:78:14: note: in instantiation of member function 'PT::TextStreamBase::to_string' requested here table_name.to_string(table_name_str); ^ /usr/home/tomek/roboczy/prog/web.ttmath.org/../pikotools/membuffer/membuffer.h:93:8: note: candidate function bool operator!=(const const_iterator & i); ^ /usr/home/tomek/roboczy/prog/web.ttmath.org/../pikotools/membuffer/membuffer.h:92:8: note: candidate function bool operator==(const const_iterator & i); ^ /usr/home/tomek/roboczy/prog/web.ttmath.org/../pikotools/membuffer/membuffer.h:92:8: note: candidate function (with reversed parameter order) --- membuffer/membuffer.h | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/membuffer/membuffer.h b/membuffer/membuffer.h index 21ef016..dea0493 100644 --- a/membuffer/membuffer.h +++ b/membuffer/membuffer.h @@ -5,7 +5,7 @@ */ /* - * Copyright (c) 2012-2013, Tomasz Sowa + * Copyright (c) 2012-2021, Tomasz Sowa * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -58,8 +58,8 @@ public: { public: - bool operator==(const iterator & i); - bool operator!=(const iterator & i); + bool operator==(const iterator & i) const; + bool operator!=(const iterator & i) const; iterator & operator++(); // prefix ++ iterator operator++(int); // postfix ++ @@ -89,8 +89,8 @@ public: const_iterator & operator=(const const_iterator & i); const_iterator & operator=(const iterator & i); - bool operator==(const const_iterator & i); - bool operator!=(const const_iterator & i); + bool operator==(const const_iterator & i) const; + bool operator!=(const const_iterator & i) const; const_iterator & operator++(); // prefix ++ const_iterator operator++(int); // postfix ++ @@ -264,7 +264,7 @@ item_type & MemBuffer::iterator::operato template -bool MemBuffer::iterator::operator==(const iterator & i) +bool MemBuffer::iterator::operator==(const iterator & i) const { return mem_buffer == i.mem_buffer && dynamic_array_index == i.dynamic_array_index && @@ -273,7 +273,7 @@ bool MemBuffer::iterator::operator==(con template -bool MemBuffer::iterator::operator!=(const iterator & i) +bool MemBuffer::iterator::operator!=(const iterator & i) const { return mem_buffer != i.mem_buffer || dynamic_array_index != i.dynamic_array_index || @@ -422,7 +422,7 @@ item_type MemBuffer::const_iterator::ope template -bool MemBuffer::const_iterator::operator==(const const_iterator & i) +bool MemBuffer::const_iterator::operator==(const const_iterator & i) const { return mem_buffer == i.mem_buffer && dynamic_array_index == i.dynamic_array_index && @@ -431,7 +431,7 @@ bool MemBuffer::const_iterator::operator template -bool MemBuffer::const_iterator::operator!=(const const_iterator & i) +bool MemBuffer::const_iterator::operator!=(const const_iterator & i) const { return mem_buffer != i.mem_buffer || dynamic_array_index != i.dynamic_array_index ||