Skip to content

Commit

Permalink
Simplify Selection::Selection.
Browse files Browse the repository at this point in the history
The modern pattern for constructors is to accept by value and move. This
avoid duplication of the ctor at the (usually) negligible cost of at
most one move.
  • Loading branch information
1uc committed Oct 24, 2023
1 parent 7a3983a commit dc6f849
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 9 deletions.
3 changes: 1 addition & 2 deletions include/bbp/sonata/population.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ class SONATA_API Selection
using Range = std::pair<Value, Value>;
using Ranges = std::vector<Range>;

explicit Selection(Ranges&& ranges);
explicit Selection(const Ranges& ranges);
Selection(Ranges ranges);

template <typename Iterator>
static Selection fromValues(Iterator first, Iterator last);
Expand Down
8 changes: 1 addition & 7 deletions src/population.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,18 +93,12 @@ Selection union_(const Ranges& lhs, const Ranges& rhs) {
} // namespace detail


Selection::Selection(Selection::Ranges&& ranges)
Selection::Selection(Selection::Ranges ranges)
: ranges_(std::move(ranges)) {
detail::_checkRanges(ranges_);
}


Selection::Selection(const Selection::Ranges& ranges)
: ranges_(ranges) {
detail::_checkRanges(ranges_);
}


Selection Selection::fromValues(const Selection::Values& values) {
return fromValues(values.begin(), values.end());
}
Expand Down

0 comments on commit dc6f849

Please sign in to comment.