Skip to content

Commit

Permalink
[hive] Fix tests for libc++'s improved C++20 support
Browse files Browse the repository at this point in the history
  • Loading branch information
Quuxplusone committed Feb 17, 2023
1 parent e0012e6 commit 56aec97
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
5 changes: 4 additions & 1 deletion benchmarks/hive_bench.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,13 @@
#undef PLF_HIVE_P2596
#undef plf

#if __cplusplus >= 202002L
#undef PLF_HIVE_H
#define plf matt
#undef __cpp_lib_hive
#include "../../plf_hive/plf_hive.h"
#undef plf
#endif // __cplusplus >= 202002L

#include <benchmark/benchmark.h>

Expand Down Expand Up @@ -63,7 +66,7 @@ struct xoshiro256ss {

#define N 1000

#if N < 256
#if __cplusplus >= 202002L && N < 256
static void BM_PlfStackIssue1_MattSmart(benchmark::State& state) {
int fake_input[N] = {};
xoshiro256ss g;
Expand Down
9 changes: 5 additions & 4 deletions test/hive_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1990,17 +1990,18 @@ TYPED_TEST(hivet, MoveOnlyInputIterator)
auto& operator++() { ++p_; return *this; }
void operator++(int) { ++p_; }
bool operator==(const MoveOnlyInputIterator& rhs) const { return p_ == rhs.p_; }
bool operator==(const Value *p) const { return p_ == p; }
#if __cplusplus < 202002L
bool operator!=(const MoveOnlyInputIterator& rhs) const { return p_ != rhs.p_; }
#if __cpp_lib_ranges >= 201911
bool operator==(Value *p) const { return p_ == p; }
bool operator!=(Value *p) const { return p_ != p; }
#endif
};

static_assert(std::is_move_constructible<MoveOnlyInputIterator>::value);
static_assert(!std::is_copy_constructible<MoveOnlyInputIterator>::value);
#if __cpp_lib_concepts >= 202002
static_assert(std::input_or_output_iterator<MoveOnlyInputIterator>);
static_assert(!std::forward_iterator<MoveOnlyInputIterator>);
static_assert(std::sentinel_for<Value*, MoveOnlyInputIterator>);
#endif

Value a[] = {
Expand Down Expand Up @@ -2678,7 +2679,7 @@ TEST(hive, SortDoesntUseAllocator)
try {
while (true) (void)mr.allocate(1);
} catch (...) { }
ASSERT_THROW(mr.allocate(1), std::bad_alloc);
ASSERT_THROW((void)mr.allocate(1), std::bad_alloc);
h.sort();
int expected[] = {1,1,3,4,5};
EXPECT_TRUE(std::equal(h.begin(), h.end(), expected, expected + 5));
Expand Down

0 comments on commit 56aec97

Please sign in to comment.