Sequoia
Loading...
Searching...
No Matches
PartitionedDataDetails.hpp
Go to the documentation of this file.
1
2// Copyright Oliver J. Rosten 2018. //
3// Distributed under the GNU GENERAL PUBLIC LICENSE, Version 3.0. //
4// (See accompanying file LICENSE.md or copy at //
5// https://www.gnu.org/licenses/gpl-3.0.en.html) //
7
8#pragma once
9
15
16namespace sequoia::data_structures::partition_impl
17{
18 template<bool Reversed, std::integral IndexType>
20 {
21 public:
22 using index_type = IndexType;
23
24 constexpr partition_index_policy() = default;
25 constexpr explicit partition_index_policy(const index_type n) : m_Partition{n} {}
26 constexpr partition_index_policy(const partition_index_policy&) = default;
27
28 constexpr static auto npos{std::numeric_limits<index_type>::max()};
29
30 [[nodiscard]]
31 constexpr static bool reversed() noexcept { return Reversed; }
32
33 [[nodiscard]]
34 friend constexpr bool operator==(const partition_index_policy& lhs, const partition_index_policy& rhs) noexcept = default;
35
36 [[nodiscard]]
37 constexpr IndexType partition_index() const noexcept { return m_Partition; }
38 protected:
39 constexpr partition_index_policy(partition_index_policy&&) noexcept = default;
40
41 ~partition_index_policy() = default;
42
43 constexpr partition_index_policy& operator=(const partition_index_policy&) = default;
44 constexpr partition_index_policy& operator=(partition_index_policy&&) noexcept = default;
45 private:
46 IndexType m_Partition{};
47 };
48
49 //============================= Helper classes for copy constructor ===================================//
50
51 template<alloc PartitionAllocator, alloc Allocator>
52 inline constexpr bool is_always_equal_v{
53 std::allocator_traits<PartitionAllocator>::is_always_equal::value
54 && std::allocator_traits<Allocator>::is_always_equal::value
55 };
56
57 template<alloc PartitionAllocator, alloc Allocator>
58 inline constexpr bool propagates_on_copy_assignment_v{
59 ( std::allocator_traits<PartitionAllocator>::propagate_on_container_copy_assignment::value
60 || std::allocator_traits<PartitionAllocator>::is_always_equal::value)
61 && ( std::allocator_traits<Allocator>::propagate_on_container_copy_assignment::value
62 || std::allocator_traits<Allocator>::is_always_equal::value)
63 };
64
65 template<alloc PartitionAllocator, alloc Allocator>
66 inline constexpr bool propagates_on_move_assignment_v{
67 ( std::allocator_traits<PartitionAllocator>::propagate_on_container_move_assignment::value
68 || std::allocator_traits<PartitionAllocator>::is_always_equal::value)
69 && ( std::allocator_traits<Allocator>::propagate_on_container_move_assignment::value
70 || std::allocator_traits<Allocator>::is_always_equal::value)
71 };
72}
Traits which are sufficiently general to appear in the sequoia namespace.