From cb122ad1e5797796b7f7612b3d5f35ce6c2bbb6f Mon Sep 17 00:00:00 2001 From: Willem Jan Withagen Date: Tue, 6 Oct 2020 02:00:28 +0200 Subject: [PATCH] include: explicitly define all types needed for libc++ iterator There is a serious difference between iterator in libstdc++ (gcc) versus libc++ (clang) This generates a rather big and vague set of warnings and notes. The crux is the warnings about `requirement '!__is_forward_iterator....` Extra information can also be found on: https://www.fluentcpp.com/2018/05/08/std-iterator-deprecated/ ``` /home/jenkins/workspace/ceph-master-compile/src/librbd/deep_copy/ObjectCopyRequest.cc:142:15: error: no matching constructor for initialization of 'io::Extents' (aka 'vector >') io::Extents image_extents{read_op.image_interval.begin(), ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /home/jenkins/workspace/ceph-master-compile/src/librbd/deep_copy/ObjectCopyRequest.cc:769:35: note: in instantiation of member function 'librbd::deep_copy::ObjectCopyRequest::send_read' requested here template class librbd::deep_copy::ObjectCopyRequest; ^ /usr/include/c++/v1/vector:516:14: note: candidate constructor not viable: no known conversion from 'interval_set::iterator' to 'std::__1::vector, std::__1::allocator > >::size_type' (aka 'unsigned long') for 1st argument explicit vector(size_type __n, const allocator_type& __a); ^ /usr/include/c++/v1/vector:518:5: note: candidate constructor not viable: no known conversion from 'interval_set::iterator' to 'std::__1::vector, std::__1::allocator > >::size_type' (aka 'unsigned long') for 1st argument vector(size_type __n, const value_type& __x); ^ /usr/include/c++/v1/vector:559:5: note: candidate constructor not viable: no known conversion from 'interval_set::iterator' to 'const std::__1::vector, std::__1::allocator > >' for 1st argument vector(const vector& __x, const allocator_type& __a); ^ /usr/include/c++/v1/vector:568:5: note: candidate constructor not viable: no known conversion from 'interval_set::iterator' to 'initializer_list, std::__1::allocator > >::value_type>' (aka 'initializer_list >') for 1st argument vector(initializer_list __il, const allocator_type& __a); ^ /usr/include/c++/v1/vector:579:5: note: candidate constructor not viable: no known conversion from 'interval_set::iterator' to 'std::__1::vector, std::__1::allocator > >' for 1st argument vector(vector&& __x, const allocator_type& __a); ^ /usr/include/c++/v1/vector:521:9: note: candidate template ignored: requirement '!__is_forward_iterator::iterator>::value' was not satisfied [with _InputIterator = interval_set::iterator] vector(_InputIterator __first, ^ /usr/include/c++/v1/vector:536:9: note: candidate template ignored: requirement 'is_constructible, unsigned long &>::value' was not satisfied [with _ForwardIterator = interval_set::iterator] vector(_ForwardIterator __first, ^ /usr/include/c++/v1/vector:502:40: note: candidate constructor not viable: requires single argument '__a', but 2 arguments were provided _LIBCPP_INLINE_VISIBILITY explicit vector(const allocator_type& __a) ^ /usr/include/c++/v1/vector:514:14: note: candidate constructor not viable: requires single argument '__n', but 2 arguments were provided explicit vector(size_type __n); ^ /usr/include/c++/v1/vector:558:5: note: candidate constructor not viable: requires single argument '__x', but 2 arguments were provided vector(const vector& __x); ^ /usr/include/c++/v1/vector:565:5: note: candidate constructor not viable: requires single argument '__il', but 2 arguments were provided vector(initializer_list __il); ^ /usr/include/c++/v1/vector:571:5: note: candidate constructor not viable: requires single argument '__x', but 2 arguments were provided vector(vector&& __x) ^ /usr/include/c++/v1/vector:519:5: note: candidate constructor not viable: requires 3 arguments, but 2 were provided vector(size_type __n, const value_type& __x, const allocator_type& __a); ^ /usr/include/c++/v1/vector:496:5: note: candidate constructor not viable: requires 0 arguments, but 2 were provided vector() _NOEXCEPT_(is_nothrow_default_constructible::value) ^ /usr/include/c++/v1/vector:529:9: note: candidate constructor template not viable: requires at least 3 arguments, but 2 were provided vector(_InputIterator __first, _InputIterator __last, const allocator_type& __a, ^ /usr/include/c++/v1/vector:543:9: note: candidate constructor template not viable: requires at least 3 arguments, but 2 were provided vector(_ForwardIterator __first, _ForwardIterator __last, const allocator_type& __a, ^ 1 error generated. ``` Signed-off-by: Willem Jan Withagen --- src/include/interval_set.h | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/include/interval_set.h b/src/include/interval_set.h index 5ff065cd55b21..7b2d994387f2b 100644 --- a/src/include/interval_set.h +++ b/src/include/interval_set.h @@ -43,9 +43,15 @@ class interval_set { class const_iterator; - class iterator : public std::iterator + class iterator { public: + using difference_type = ssize_t; + using value_type = typename Map::value_type; + using pointer = typename Map::value_type*; + using reference = typename Map::value_type&; + using iterator_category = std::forward_iterator_tag; + explicit iterator(typename Map::iterator iter) : _iter(iter) { } -- 2.39.5