]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
include/denc: redefine is_const_iterator
authorKefu Chai <tchaikov@gmail.com>
Sun, 21 Aug 2022 00:23:00 +0000 (08:23 +0800)
committerKefu Chai <tchaikov@gmail.com>
Sun, 21 Aug 2022 02:09:14 +0000 (10:09 +0800)
to just check for the return type of `it.get_pos_add(n)`, this
is exactly what we expect from a buffer::ptr::const_iterator.
it is more specific and less confusing.

Signed-off-by: Kefu Chai <tchaikov@gmail.com>
src/include/denc.h

index 96b7e7c099fc7bb258398efe39f4176bf62b10b0..b8982fa2110da509a0c69f39b357a3a723d1eefc 100644 (file)
@@ -26,6 +26,7 @@
 
 #include <array>
 #include <cstring>
+#include <concepts>
 #include <map>
 #include <optional>
 #include <set>
@@ -283,8 +284,9 @@ using underlying_type_t = typename underlying_type<T>::type;
 }
 
 template<class It>
-concept is_const_iterator =
-std::is_const_v<std::remove_pointer_t<typename It::pointer>>;
+concept is_const_iterator = requires(It& it, size_t n) {
+  { it.get_pos_add(n) } -> std::same_as<const char*>;
+};
 
 template<typename T, is_const_iterator It>
 const T& get_pos_add(It& i) {