13 #ifdef __cpp_constexpr_dynamic_alloc
19 constexpr DynArray() =
default;
21 constexpr
explicit DynArray(std::size_t n) : data(new T[n]{})
25 DynArray(
const DynArray&) =
delete;
26 DynArray(DynArray&&) =
delete;
27 auto operator=(
const DynArray&) -> DynArray& =
delete;
28 auto operator=(DynArray&&) -> DynArray& =
delete;
35 constexpr
void resize(std::size_t n)
49 template<
typename Mapping>
50 constexpr
auto mapsNonOverlappingly(
const Mapping& m) ->
bool
52 internal::DynArray<internal::DynArray<std::uint64_t>> blobByteMapped(m.blobCount);
53 for(std::size_t i = 0; i < m.blobCount; i++)
54 blobByteMapped.data[i].resize(
divCeil(m.blobSize(i), std::size_t{64}));
56 auto testAndSet = [&](
auto blob,
auto offset) constexpr
58 const auto bit = std::uint64_t{1} << (offset % 64);
59 if(blobByteMapped.data[blob].data[offset / 64] & bit)
61 blobByteMapped.data[blob].data[offset / 64] |= bit;
65 bool collision =
false;
66 forEachLeafCoord<typename Mapping::RecordDim>(
67 [&](
auto rc) constexpr
71 for(
auto ai : ArrayIndexRange{m.extents()})
73 using Type =
GetType<
typename Mapping::RecordDim, decltype(rc)>;
74 const auto [blob, offset] = m.blobNrAndOffset(ai, rc);
75 for(std::size_t b = 0; b <
sizeof(Type); b++)
76 if(testAndSet(blob, offset + b))
92 template<std::
size_t PieceLength,
typename Mapping>
95 bool collision =
false;
96 forEachLeafCoord<typename Mapping::RecordDim>(
97 [&](
auto rc) constexpr
99 std::size_t flatIndex = 0;
100 std::size_t lastBlob = std::numeric_limits<std::size_t>::max();
101 std::size_t lastOffset = std::numeric_limits<std::size_t>::max();
104 using Type =
GetType<
typename Mapping::RecordDim, decltype(rc)>;
105 const auto [blob, offset] = m.blobNrAndOffset(ai, rc);
106 if(flatIndex % PieceLength != 0 && (lastBlob != blob || lastOffset +
sizeof(Type) != offset))
constexpr auto mapsPiecewiseContiguous(const Mapping &m) -> bool
constexpr auto divCeil(Integral a, Integral b) -> Integral
Returns the ceiling of a / b.
typename internal::GetTypeImpl< RecordDim, RecordCoordOrTags... >::type GetType
Range allowing to iterate over all indices in an ArrayExtents.