Skip to content
Snippets Groups Projects
Commit bc566ecb authored by Vasileios Karakasis's avatar Vasileios Karakasis
Browse files

Reverted semantics of assign_by.

The problem described in previous commit was caused only inside the
cell's copy constructor, where an assignemt for `std::unique_ptr` was
attempted. Since `std::unique_ptr`'s cannot be copy-assigned, I have
made that assignment manually moving the just cloned other's segment to
the cell being constructed. The original `assign_by` method, relying on
STL's `assign()` cannot accommodate this without changing its
semantics (as pointed out by @halfflat), which would then also conflict
with STL's semantics.
parent 870d5eb7
No related branches found
No related tags found
No related merge requests found
......@@ -90,8 +90,11 @@ public:
spike_detectors_(other.spike_detectors_),
probes_(other.probes_)
{
util::assign_by(segments_, other.segments_,
[](const segment_ptr& p) { return p->clone(); });
// unique_ptr's cannot be copy constructed, do a manual assignment
auto siter = segments_.begin();
for (const auto& s : other.segments_) {
*siter = std::move(s->clone());
}
}
/// add a soma to the cell
......
......@@ -62,37 +62,13 @@ Container& append(Container &c, const Seq& seq) {
// Assign sequence to a container
template <typename AssignableContainer, typename Seq>
enable_if_t<
std::is_copy_constructible<typename AssignableContainer::value_type>::value,
AssignableContainer&
>
assign(AssignableContainer& c, const Seq& seq) {
AssignableContainer& assign(AssignableContainer& c, const Seq& seq) {
auto canon = canonical_view(seq);
c.assign(std::begin(canon), std::end(canon));
return c;
}
// This version of assing is needed for assigning segment_ptr's (i.e.,
// unique_ptr's) with Clang
template<typename AssignableContainer, typename Seq>
enable_if_t<
!std::is_copy_constructible<typename AssignableContainer::value_type>::value &&
std::is_move_constructible<typename AssignableContainer::value_type>::value,
AssignableContainer&
>
assign(AssignableContainer& c, const Seq& seq)
{
auto citer = c.begin();
for (auto s : canonical_view(seq)) {
*citer = std::move(s);
}
return c;
}
// Assign sequence to a container with transform `proj`
template <typename AssignableContainer, typename Seq, typename Proj>
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment