Skip to content

Commit

Permalink
explicit dynarray copy constructor
Browse files Browse the repository at this point in the history
Also operator =(const dynarray &&) = delete
  • Loading branch information
OleErikPeistorpet committed Jun 6, 2024
1 parent 0bd4b90 commit 7725cd7
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions dynarray.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,16 +101,17 @@ class dynarray

dynarray(dynarray && other) noexcept : _m(std::move(other._m)) {}
dynarray(dynarray && other, Alloc a);
dynarray(const dynarray & other) : dynarray(other,
explicit dynarray(const dynarray & other) : dynarray(other,
_alloTrait::select_on_container_copy_construction(other._m)) {}
dynarray(const dynarray & other, Alloc a) : _m(a) { append(other); }
explicit dynarray(const dynarray & other, Alloc a) : _m(a) { append(other); }

~dynarray() noexcept;

dynarray & operator =(dynarray && other) &
noexcept(_alloTrait::propagate_on_container_move_assignment::value or _alloTrait::is_always_equal::value);
//! Requires that allocator_type is always equal or does not have propagate_on_container_copy_assignment
dynarray & operator =(const dynarray & other) &;
dynarray & operator =(const dynarray &&) = delete;

dynarray & operator =(std::initializer_list<T> il) & { assign(il); return *this; }

Expand Down
2 changes: 1 addition & 1 deletion unit_test/dynarray_mutate_gtest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -831,7 +831,7 @@ TEST_F(dynarrayTest, erasePrecondCheck)
leakDetector->enabled = false;

dynarray<int> di{-2};
auto copy = di;
auto copy = dynarray(di);
ASSERT_DEATH( copy.erase(di.begin()), "" );
}

Expand Down

0 comments on commit 7725cd7

Please sign in to comment.