Skip to content

Commit

Permalink
Improve some contructors and the move asignment operator
Browse files Browse the repository at this point in the history
  • Loading branch information
tpadioleau committed Mar 10, 2022
1 parent 0d26ab7 commit 23cddab
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions include/ddc/chunk.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ class Chunk<ElementType, DiscreteDomain<DDims...>, Allocator>

/// Construct a Chunk on a domain with uninitialized values
explicit Chunk(mdomain_type const& domain, Allocator const& allocator = Allocator())
: m_allocator(allocator)
: base_type()
, m_allocator(allocator)
{
static_cast<base_type&>(*this) = base_type(
std::allocator_traits<Allocator>::allocate(m_allocator, domain.size()),
Expand All @@ -96,7 +97,9 @@ class Chunk<ElementType, DiscreteDomain<DDims...>, Allocator>
/** Constructs a new Chunk by move
* @param other the Chunk to move
*/
Chunk(Chunk&& other) : base_type(std::move(other))
Chunk(Chunk&& other)
: base_type(std::move(static_cast<base_type&>(other)))
, m_allocator(std::move(other.m_allocator))
{
other.m_internal_mdspan = internal_mdspan_type();
}
Expand All @@ -117,7 +120,9 @@ class Chunk<ElementType, DiscreteDomain<DDims...>, Allocator>
*/
Chunk& operator=(Chunk&& other)
{
static_cast<base_type&>(*this) = std::move(other);
static_cast<base_type&>(*this) = std::move(static_cast<base_type&>(other));
m_allocator = std::move(other.m_allocator);

other.m_internal_mdspan = internal_mdspan_type();
return *this;
}
Expand Down

0 comments on commit 23cddab

Please sign in to comment.