From cc063d5395a25db9a675f6012e4c204057485a31 Mon Sep 17 00:00:00 2001 From: Casey Bodley Date: Fri, 11 Feb 2022 18:26:22 -0500 Subject: [PATCH] buffer: constrain conversions of buffers_t iterators prevent conversions from const_iterator -> iterator to resolve a c++20 compilation error with clang 13: ceph/src/include/buffer.h:537:18: error: use of overloaded operator '==' is ambiguous (with operand types 'ceph::buffer::list::buffers_t::const_iterator' (aka 'buffers_iterator') and 'ceph::buffer::list::buffers_t::iterator' (aka 'buffers_iterator' )) _root.next = it == end() ? &item : _root.next; ~~ ^ ~~~~~ ceph/src/include/buffer.h:471:7: note: candidate function bool operator==(const buffers_iterator& rhs) const { ^ ceph/src/include/buffer.h:471:7: note: candidate function (with reversed parameter order) Signed-off-by: Casey Bodley --- src/include/buffer.h | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/include/buffer.h b/src/include/buffer.h index 8a28d846d9d..5e3fdf4b40b 100644 --- a/src/include/buffer.h +++ b/src/include/buffer.h @@ -440,7 +440,13 @@ struct error_code; buffers_iterator(U* const p) : cur(p) { } - template + // copy constructor + buffers_iterator(const buffers_iterator& other) + : cur(other.cur) { + } + // converting constructor, from iterator -> const_iterator only + template ::value && !std::is_const::value, int>::type = 0> buffers_iterator(const buffers_iterator& other) : cur(other.cur) { } @@ -475,11 +481,6 @@ struct error_code; bool operator!=(const buffers_iterator& rhs) const { return !(*this==rhs); } - - using citer_t = buffers_iterator::type>; - operator citer_t() const { - return citer_t(cur); - } }; typedef buffers_iterator const_iterator; -- 2.39.5