From 801c68bdc9fc86f21f25f905c2465eb5da98ca26 Mon Sep 17 00:00:00 2001 From: Daniil Goncharov Date: Sat, 25 May 2024 17:35:16 +0300 Subject: [PATCH] fix wshadow (#354) --- example/CMakeLists.txt | 2 +- include/magic_enum/magic_enum_containers.hpp | 8 ++++---- test/CMakeLists.txt | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/example/CMakeLists.txt b/example/CMakeLists.txt index e990d63d4..1fa78d01d 100644 --- a/example/CMakeLists.txt +++ b/example/CMakeLists.txt @@ -2,7 +2,7 @@ include(CheckCXXCompilerFlag) set(CMAKE_CXX_STANDARD 17) if((CMAKE_CXX_COMPILER_ID MATCHES "GNU") OR (CMAKE_CXX_COMPILER_ID MATCHES "Clang")) - set(OPTIONS -Wall -Wextra -pedantic-errors -Werror) + set(OPTIONS -Wall -Wextra -Wshadow -pedantic-errors -Werror) elseif(CMAKE_CXX_COMPILER_ID MATCHES "MSVC") set(OPTIONS /W4 /WX) if(HAS_PERMISSIVE_FLAG) diff --git a/include/magic_enum/magic_enum_containers.hpp b/include/magic_enum/magic_enum_containers.hpp index f042abe78..6ccd82a6a 100644 --- a/include/magic_enum/magic_enum_containers.hpp +++ b/include/magic_enum/magic_enum_containers.hpp @@ -264,8 +264,8 @@ struct FilteredIterator { constexpr explicit FilteredIterator(const FilteredIterator& other) : parent(other.parent), first(other.first), last(other.last), current(other.current), getter(other.getter), predicate(other.predicate) {} - constexpr FilteredIterator(Parent p, Iterator begin, Iterator end, Iterator curr, Getter getter = {}, Predicate pred = {}) - : parent(p), first(std::move(begin)), last(std::move(end)), current(std::move(curr)), getter{std::move(getter)}, predicate{std::move(pred)} { + constexpr FilteredIterator(Parent p, Iterator begin, Iterator end, Iterator curr, Getter get = {}, Predicate pred = {}) + : parent(p), first(std::move(begin)), last(std::move(end)), current(std::move(curr)), getter{std::move(get)}, predicate{std::move(pred)} { if (current == first && !predicate(parent, current)) { ++*this; } @@ -501,9 +501,9 @@ class bitset { std::size_t num_index; base_type bit_index; - constexpr reference_impl(parent_t parent, std::size_t ix) noexcept : reference_impl(parent, std::pair{ix / bits_per_base, base_type{1} << (ix % bits_per_base)}) {} + constexpr reference_impl(parent_t p, std::size_t i) noexcept : reference_impl(p, std::pair{i / bits_per_base, base_type{1} << (i % bits_per_base)}) {} - constexpr reference_impl(parent_t parent, std::pair ix) noexcept : parent(parent), num_index(std::get<0>(ix)), bit_index(std::get<1>(ix)) {} + constexpr reference_impl(parent_t p, std::pair i) noexcept : parent(p), num_index(std::get<0>(i)), bit_index(std::get<1>(i)) {} public: constexpr reference_impl& operator=(bool v) noexcept { diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 8c2076271..d74755cf5 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -12,7 +12,7 @@ if(CMAKE_CXX_COMPILER_ID MATCHES "MSVC") check_cxx_compiler_flag(/std:c++latest HAS_CPPLATEST_FLAG) elseif(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang") set(CMAKE_VERBOSE_MAKEFILE ON) - set(OPTIONS -Wall -Wextra -pedantic-errors -Werror) + set(OPTIONS -Wall -Wextra -Wshadow -pedantic-errors -Werror) check_cxx_compiler_flag(-std=c++20 HAS_CPP20_FLAG) check_cxx_compiler_flag(-std=c++23 HAS_CPP23_FLAG)