mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Convert operator+(Population, Population) into a hidden friend
This commit is contained in:
@@ -118,15 +118,21 @@ Population Population::crossover(PairSelection const& _selection, function<Cross
|
||||
return Population(m_fitnessMetric, crossedIndividuals);
|
||||
}
|
||||
|
||||
namespace solidity::phaser
|
||||
{
|
||||
|
||||
Population operator+(Population _a, Population _b)
|
||||
{
|
||||
// This operator is meant to be used only with populations sharing the same metric (and, to make
|
||||
// things simple, "the same" here means the same exact object in memory).
|
||||
assert(_a.m_fitnessMetric == _b.m_fitnessMetric);
|
||||
|
||||
using ::operator+; // Import the std::vector concat operator from CommonData.h
|
||||
return Population(_a.m_fitnessMetric, move(_a.m_individuals) + move(_b.m_individuals));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
bool Population::operator==(Population const& _other) const
|
||||
{
|
||||
// We consider populations identical only if they share the same exact instance of the metric.
|
||||
|
||||
Reference in New Issue
Block a user