Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
  • Loading branch information
crtrott committed May 2, 2024
1 parent 3be9245 commit 65d2066
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion include/experimental/__p0009_bits/extents.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -541,7 +541,7 @@ template <class IndexType, size_t... Extents> class extents {
operator==(const extents &lhs,
const extents<OtherIndexType, OtherExtents...> &rhs) noexcept {
return
rank() == extents<OtherIndexType, OtherExtents...>::rank() and
rank() == extents<OtherIndexType, OtherExtents...>::rank() &&
detail::rankwise_equal(detail::with_rank<rank()>{}, rhs, lhs, detail::extent);
}

Expand Down
4 changes: 2 additions & 2 deletions include/experimental/__p0009_bits/layout_stride.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -597,8 +597,8 @@ constexpr void validate_strides(with_rank<N>, 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);
}
Expand Down
14 changes: 7 additions & 7 deletions include/experimental/__p0009_bits/macros.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 <bool skip = MDSPAN_SKIP_PRECONDITION_VIOLATION_HANDLER>
template <bool skip = MDSPAN_IMPL_SKIP_PRECONDITION_VIOLATION_HANDLER>
constexpr void precondition(const char* cond, const char* file, unsigned line)
{
if (skip) { return; }
Expand All @@ -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__); \
Expand Down
6 changes: 3 additions & 3 deletions tests/test_alternate_precondition_violation_handler.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include <stdexcept>

#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);
Expand All @@ -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)
Expand All @@ -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;
}
};
Expand Down
4 changes: 2 additions & 2 deletions tests/test_macros.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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;
}
};
Expand Down

0 comments on commit 65d2066

Please sign in to comment.