@@ -2386,263 +2386,4 @@ TYPED_TEST(Erasure, ByPred) {
23862386 GTEST_SKIP () << " Not implemented" ;
23872387}
23882388
2389- #if 0
2390-
2391- template <typename T> class InplaceVectorSMFs : public ::testing::Test {
2392- public:
2393- using IV = beman::inplace_vector::inplace_vector<T, 10>;
2394- using IV0 = beman::inplace_vector::inplace_vector<T, 0>;
2395-
2396- struct InputIterator {
2397- using difference_type = std::ptrdiff_t;
2398- using value_type = T;
2399- using iterator_category = std::input_iterator_tag;
2400-
2401- T step;
2402- explicit constexpr InputIterator(T n) noexcept : step(n) {}
2403- constexpr InputIterator &operator++() noexcept {
2404- ++step.value;
2405- return *this;
2406- }
2407- constexpr InputIterator operator++(int) noexcept {
2408- auto prev = *this;
2409- ++(*this);
2410- return prev;
2411- }
2412- constexpr T operator*() const noexcept { return step; }
2413- constexpr bool operator==(InputIterator const &) const noexcept = default;
2414- };
2415- static_assert(std::input_iterator<InputIterator>);
2416- };
2417-
2418- using AllTypes =
2419- ::testing::Types<Trivial, NonTriviallyDefaultConstructible,
2420- NonTriviallyCopyConstructible,
2421- NonTriviallyMoveConstructible, NonTriviallyCopyAssignable,
2422- NonTriviallyMoveAssignable, TriviallyAssignable,
2423- TriviallyDestructible, NonTrivial>;
2424- TYPED_TEST_SUITE(InplaceVectorSMFs, AllTypes);
2425-
2426- // [containers.sequences.inplace.vector.cons]
2427- TYPED_TEST(InplaceVectorSMFs, ConsDefault) {
2428- using IV = TestFixture::IV;
2429- using IV0 = TestFixture::IV0;
2430-
2431- IV v;
2432- EXPECT_EQ(v.size(), 0u);
2433-
2434- IV0 v0;
2435- EXPECT_EQ(v0.size(), 0u);
2436-
2437- if constexpr (std::is_trivial_v<TypeParam>) {
2438- constexpr IV cv;
2439- static_assert(cv.size() == 0u);
2440-
2441- constexpr IV0 cv0;
2442- static_assert(cv0.size() == 0u);
2443- }
2444- }
2445-
2446- // [containers.sequences.inplace.vector.cons]
2447- TYPED_TEST(InplaceVectorSMFs, ConsSize) {
2448- using IV = TestFixture::IV;
2449- using IV0 = TestFixture::IV0;
2450- using T = TypeParam;
2451-
2452- IV v(IV::capacity());
2453- EXPECT_EQ(v.size(), IV::capacity());
2454- for (auto const &elem : v) {
2455- EXPECT_EQ(elem, T{});
2456- }
2457-
2458- IV0 v0(0u);
2459- EXPECT_EQ(v0.size(), 0u);
2460-
2461- if constexpr (false && /* TODO */ std::is_trivial_v<TypeParam>) {
2462- constexpr IV cv(IV::capacity());
2463- static_assert(IV::capacity());
2464- constexpr auto default_inserted = [](IV const &v) {
2465- for (auto const &elem : v) {
2466- if (elem != T{}) {
2467- return false;
2468- }
2469- }
2470- return true;
2471- };
2472- static_assert(default_inserted(cv));
2473-
2474- constexpr IV0 cv0(0);
2475- static_assert(cv0.size() == 0u);
2476- }
2477-
2478- // [containers.sequences.inplace.vector.overview]
2479- // 5. Any member function of inplace_vector<T, N> that would cause the size to
2480- // exceed N throws an exception of type bad_alloc.
2481- EXPECT_THROW(IV v(IV::capacity() + 1u), std::bad_alloc);
2482- EXPECT_THROW(IV0 v0(1u), std::bad_alloc);
2483- }
2484-
2485- // [containers.sequences.inplace.vector.cons]
2486- TYPED_TEST(InplaceVectorSMFs, ConsSizeValue) {
2487- using IV = TestFixture::IV;
2488- using IV0 = TestFixture::IV0;
2489- using T = TypeParam;
2490-
2491- IV v(IV::capacity(), T{42});
2492- // [sequence.reqmts]
2493- EXPECT_EQ(static_cast<IV::size_type>(std::distance(v.begin(), v.end())),
2494- IV::capacity());
2495- for (auto const &elem : v) {
2496- EXPECT_EQ(elem, T{42});
2497- }
2498-
2499- IV0 v0(0u, T{42});
2500- EXPECT_EQ(v0.size(), 0u);
2501-
2502- if constexpr (false && /* TODO */ std::is_trivial_v<TypeParam>) {
2503- constexpr IV cv(IV::capacity(), T{42});
2504- // [sequence.reqmts]
2505- static_assert(std::distance(v.begin(), v.end()) == IV::capacity());
2506- constexpr auto all_of = [](IV const &v, T const &x) {
2507- for (auto const &elem : v) {
2508- if (elem != x) {
2509- return false;
2510- }
2511- }
2512- return true;
2513- };
2514- static_assert(all_of(cv, T{42}));
2515-
2516- constexpr IV0 cv0(0);
2517- static_assert(cv0.size() == 0u);
2518- }
2519-
2520- // [containers.sequences.inplace.vector.overview]
2521- // 5. Any member function of inplace_vector<T, N> that would cause the size to
2522- // exceed N throws an exception of type bad_alloc.
2523- EXPECT_THROW(IV v(IV::capacity() + 1u, T{5}), std::bad_alloc);
2524- EXPECT_THROW(IV0 v0(1u, T{5}), std::bad_alloc);
2525- }
2526-
2527- // [containers.sequences.inplace.vector.cons]
2528- TYPED_TEST(InplaceVectorSMFs, ConsIterator) {
2529- using IV = TestFixture::IV;
2530- using IV0 = TestFixture::IV0;
2531- using T = TypeParam;
2532- using InputIterator = TestFixture::InputIterator;
2533-
2534- constexpr auto first = InputIterator{T{0}};
2535- constexpr auto last = InputIterator{T{5}};
2536- IV v(first, last);
2537- EXPECT_EQ(std::distance(v.begin(), v.end()), std::distance(first, last));
2538- for (int i = 0; i < v.size(); ++i) {
2539- EXPECT_EQ(v[i], T{i});
2540- }
2541-
2542- IV0 v0(first, first);
2543- EXPECT_EQ(v0.size(), 0u);
2544-
2545- if constexpr (false && /* TODO */ std::is_trivial_v<TypeParam>) {
2546- constexpr IV cv(first, last);
2547- static_assert(std::distance(cv.begin(), cv.end()) ==
2548- std::distance(first, last));
2549- static_assert(cv[0] == T{0});
2550- static_assert(cv[1] == T{1});
2551- static_assert(cv[2] == T{2});
2552- static_assert(cv[3] == T{3});
2553- static_assert(cv[4] == T{4});
2554-
2555- constexpr IV0 cv0(first, first);
2556- static_assert(cv0.size() == 0u);
2557- }
2558-
2559- // [containers.sequences.inplace.vector.overview]
2560- // 5. Any member function of inplace_vector<T, N> that would cause the size to
2561- // exceed N throws an exception of type bad_alloc.
2562- EXPECT_THROW(IV v(first, InputIterator{T{IV::capacity() + 1}}),
2563- std::bad_alloc);
2564- EXPECT_THROW(IV0 v0(first, last), std::bad_alloc);
2565- }
2566-
2567- // [containers.sequences.inplace.vector.cons]
2568- #if defined(__cpp_lib_containers_ranges)
2569- TYPED_TEST(InplaceVectorSMFs, ConsRange) {
2570- using IV = TestFixture::IV;
2571- using IV0 = TestFixture::IV0;
2572- using T = TypeParam;
2573- using Range = std::array<T, IV::capacity()>;
2574- using Range0 = std::array<T, 0>;
2575- using Range_too_large = std::array<T, IV::capacity() + 1>;
2576-
2577- Range r;
2578- r.fill(T{42});
2579- IV v(std::from_range, r);
2580- EXPECT_EQ(v.size(), r.size());
2581- for (std::size_t idx = 0u; idx < v.size(); ++idx) {
2582- EXPECT_EQ(v[idx], r[idx]);
2583- }
2584-
2585- constexpr Range0 const r0;
2586- IV0 v0(std::from_range, r0);
2587- EXPECT_EQ(v0.size(), 0u);
2588-
2589- if constexpr (/*false && TODO */ std::is_trivial_v<TypeParam>) {
2590- constexpr Range cr{42, 99, 3, 4, 7, 1024};
2591- constexpr IV cv(std::from_range, r);
2592- static_assert(v.size() == r.size());
2593- constexpr auto range_equal = [](auto const &r1, auto const &r2) {
2594- auto f1 = std::begin(r1);
2595- auto f2 = std::begin(r2);
2596- auto const l1 = std::end(r1);
2597- auto const l2 = std::end(r2);
2598- for (; f1 != l1 && f2 != l2; ++f1, ++f2) {
2599- if (*f1 != *f2) {
2600- return false;
2601- }
2602- }
2603- return (f1 == l1) && (f2 == l2);
2604- };
2605- static_assert(range_equal(cv, r));
2606-
2607- constexpr IV0 cv0(std::from_range, r0);
2608- static_assert(cv0.size() == 0u);
2609- }
2610-
2611- // [containers.sequences.inplace.vector.overview]
2612- // 5. Any member function of inplace_vector<T, N> that would cause the size to
2613- // exceed N throws an exception of type bad_alloc.
2614- EXPECT_THROW(IV v(std::from_range, Range_too_large{}), std::bad_alloc);
2615- EXPECT_THROW(IV0 v0(std::from_range, r), std::bad_alloc);
2616- }
2617- #endif // defined(__cpp_lib_containers_ranges)
2618-
2619- // [sequence.reqmts]
2620- TYPED_TEST(InplaceVectorSMFs, ConsInitList) {
2621- using IV = TestFixture::IV;
2622- using IV0 = TestFixture::IV0;
2623- using T = TypeParam;
2624-
2625- std::initializer_list<T> const il = {T{0}, T{1}, T{2}, T{3}, T{4},
2626- T{5}, T{6}, T{7}, T{8}, T{9}};
2627- IV v(il);
2628- EXPECT_EQ(std::distance(v.begin(), v.end()),
2629- std::distance(il.begin(), il.end()));
2630- for (std::size_t i = 0; i < v.size(); ++i) {
2631- EXPECT_EQ(v[i], T(i));
2632- }
2633-
2634- constexpr std::initializer_list<T> il0 = {};
2635- IV0 v0(il0);
2636- EXPECT_EQ(v0.size(), 0u);
2637-
2638- // [containers.sequences.inplace.vector.overview]
2639- // 5. Any member function of inplace_vector<T, N> that would cause the size to
2640- // exceed N throws an exception of type bad_alloc.
2641- std::initializer_list<T> const il_too_large = {
2642- T{0}, T{1}, T{2}, T{3}, T{4}, T{5}, T{6}, T{7}, T{8}, T{9}, T{10}};
2643- EXPECT_THROW(IV v(il_too_large), std::bad_alloc);
2644- EXPECT_THROW(IV0 v0(il), std::bad_alloc);
2645- }
2646- #endif
2647-
26482389} // namespace
0 commit comments