Merge pull request #8539 from random-internet-cat/population-op-plus

Convert operator+(Population, Population) into a hidden friend
This commit is contained in:
chriseth
2020-03-30 16:22:57 +02:00
committed by GitHub
2 changed files with 8 additions and 12 deletions
+6
View File
@@ -117,15 +117,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.