From 78ae165096f2d98e8dc076bc6e74c63023e88d21 Mon Sep 17 00:00:00 2001 From: Sergey Vidyuk Date: Mon, 13 Mar 2023 10:21:58 +0700 Subject: [PATCH] Fix for case when vector iterator is raw pointer We are using patched libc++ which uses raw pointers for vector itrators to improve code compilation speed. This commit fixed two compilation issues in toml11: * location::const_iterator deinition assumes that vector const_iterator is struct or class type rather than raw pointer. * `const const_itetr foo()` triggers `-Wignored-qualifiers` for primitive types and `void` which breaks `-Wextra -Werror` compilation. --- toml/region.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/toml/region.hpp b/toml/region.hpp index 8c4f2f1..72a6f11 100644 --- a/toml/region.hpp +++ b/toml/region.hpp @@ -70,7 +70,7 @@ struct region_base struct location final : public region_base { using const_iterator = typename std::vector::const_iterator; - using difference_type = typename const_iterator::difference_type; + using difference_type = typename std::iterator_traits::difference_type; using source_ptr = std::shared_ptr>; location(std::string source_name, std::vector cont) @@ -92,7 +92,7 @@ struct location final : public region_base char front() const noexcept override {return *iter_;} // this const prohibits codes like `++(loc.iter())`. - const const_iterator iter() const noexcept {return iter_;} + std::add_const::type iter() const noexcept {return iter_;} const_iterator begin() const noexcept {return source_->cbegin();} const_iterator end() const noexcept {return source_->cend();}