From 3971ec2d87e6501225954c5e73132c895e01387b Mon Sep 17 00:00:00 2001 From: Christian Trott Date: Thu, 2 May 2024 15:16:29 -0600 Subject: [PATCH] Apply suggestions from code review --- include/experimental/__p0009_bits/extents.hpp | 2 +- .../experimental/__p0009_bits/layout_stride.hpp | 4 ++-- include/experimental/__p0009_bits/macros.hpp | 14 +++++++------- ...st_alternate_precondition_violation_handler.cpp | 6 +++--- tests/test_macros.cpp | 4 ++-- 5 files changed, 15 insertions(+), 15 deletions(-) diff --git a/include/experimental/__p0009_bits/extents.hpp b/include/experimental/__p0009_bits/extents.hpp index e730fd4f..fcb5cf92 100644 --- a/include/experimental/__p0009_bits/extents.hpp +++ b/include/experimental/__p0009_bits/extents.hpp @@ -540,7 +540,7 @@ template class extents { operator==(const extents &lhs, const extents &rhs) noexcept { return - rank() == extents::rank() and + rank() == extents::rank() && detail::rankwise_equal(detail::with_rank{}, rhs, lhs, detail::extent); } diff --git a/include/experimental/__p0009_bits/layout_stride.hpp b/include/experimental/__p0009_bits/layout_stride.hpp index b06d204f..2ccdf534 100644 --- a/include/experimental/__p0009_bits/layout_stride.hpp +++ b/include/experimental/__p0009_bits/layout_stride.hpp @@ -596,8 +596,8 @@ constexpr void validate_strides(with_rank, Layout, const Extents& ext, const for (std::size_t r = 0; r < N; r++) { const std::size_t s = is_left ? r : N - 1 - r; - MDSPAN_PRECONDITION(common_integral_compare(stride, other.stride(s)) - and "invalid strides for layout_{left,right}"); + MDSPAN_IMPL_PRECONDITION(common_integral_compare(stride, other.stride(s)) + and "invalid strides for layout_{left,right}"); stride *= ext.extent(s); } diff --git a/include/experimental/__p0009_bits/macros.hpp b/include/experimental/__p0009_bits/macros.hpp index 5b3992b1..99c4e96d 100644 --- a/include/experimental/__p0009_bits/macros.hpp +++ b/include/experimental/__p0009_bits/macros.hpp @@ -115,23 +115,23 @@ inline void default_precondition_violation_handler(const char* cond, const char* } // namespace detail } // namespace MDSPAN_IMPL_STANDARD_NAMESPACE -#ifndef MDSPAN_PRECONDITION_VIOLATION_HANDLER -#define MDSPAN_PRECONDITION_VIOLATION_HANDLER(cond, file, line) \ +#ifndef MDSPAN_IMPL_PRECONDITION_VIOLATION_HANDLER +#define MDSPAN_IMPL_PRECONDITION_VIOLATION_HANDLER(cond, file, line) \ MDSPAN_IMPL_STANDARD_NAMESPACE::detail::default_precondition_violation_handler(cond, file, line) #endif -#ifndef MDSPAN_SKIP_PRECONDITION_VIOLATION_HANDLER +#ifndef MDSPAN_IMPL_SKIP_PRECONDITION_VIOLATION_HANDLER #ifndef NDEBUG - #define MDSPAN_SKIP_PRECONDITION_VIOLATION_HANDLER 0 + #define MDSPAN_IMPL_SKIP_PRECONDITION_VIOLATION_HANDLER 0 #else - #define MDSPAN_SKIP_PRECONDITION_VIOLATION_HANDLER 1 + #define MDSPAN_IMPL_SKIP_PRECONDITION_VIOLATION_HANDLER 1 #endif #endif namespace MDSPAN_IMPL_STANDARD_NAMESPACE { namespace detail { -template +template constexpr void precondition(const char* cond, const char* file, unsigned line) { if (skip) { return; } @@ -142,7 +142,7 @@ constexpr void precondition(const char* cond, const char* file, unsigned line) } // namespace detail } // namespace MDSPAN_IMPL_STANDARD_NAMESPACE -#define MDSPAN_PRECONDITION(...) \ +#define MDSPAN_IMPL_PRECONDITION(...) \ do { \ if (not (__VA_ARGS__)) { \ MDSPAN_IMPL_STANDARD_NAMESPACE::detail::precondition(#__VA_ARGS__, __FILE__, __LINE__); \ diff --git a/tests/test_alternate_precondition_violation_handler.cpp b/tests/test_alternate_precondition_violation_handler.cpp index 0068caa4..1cc3998b 100644 --- a/tests/test_alternate_precondition_violation_handler.cpp +++ b/tests/test_alternate_precondition_violation_handler.cpp @@ -1,6 +1,6 @@ #include -#define MDSPAN_PRECONDITION_VIOLATION_HANDLER(cond, file, line) \ +#define MDSPAN_IMPL_PRECONDITION_VIOLATION_HANDLER(cond, file, line) \ do { \ throw std::logic_error{"precondition failure"}; \ } while (0); @@ -10,7 +10,7 @@ TEST(mdspan_macros, alternate_precondition_violation_handler) { - ASSERT_THROW(MDSPAN_PRECONDITION(false), std::logic_error); + ASSERT_THROW(MDSPAN_IMPL_PRECONDITION(false), std::logic_error); } TEST(mdspan_macros, alternate_precondition_check_constexpr_invocable) @@ -19,7 +19,7 @@ TEST(mdspan_macros, alternate_precondition_check_constexpr_invocable) { constexpr auto operator()() const { - MDSPAN_PRECONDITION(1 + 1 == 2); + MDSPAN_IMPL_PRECONDITION(1 + 1 == 2); return 42; } }; diff --git a/tests/test_macros.cpp b/tests/test_macros.cpp index 8e8cd752..b9e584bd 100644 --- a/tests/test_macros.cpp +++ b/tests/test_macros.cpp @@ -5,7 +5,7 @@ TEST(mdspan_macros, precondition_violation) { constexpr auto msg = "hello, world!"; - ASSERT_DEATH(MDSPAN_PRECONDITION(false and "hello, world!"), msg); + ASSERT_DEATH(MDSPAN_IMPL_PRECONDITION(false and "hello, world!"), msg); } TEST(mdspan_macros, precondition_check_constexpr_invocable) @@ -14,7 +14,7 @@ TEST(mdspan_macros, precondition_check_constexpr_invocable) { constexpr auto operator()() const { - MDSPAN_PRECONDITION(1 + 1 == 2); + MDSPAN_IMPL_PRECONDITION(1 + 1 == 2); return 42; } };