mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Add std:: qualifier to move() calls
This commit is contained in:
@@ -43,7 +43,7 @@ Chromosome Chromosome::makeRandom(size_t _length)
|
||||
for (size_t i = 0; i < _length; ++i)
|
||||
steps.push_back(randomOptimisationStep());
|
||||
|
||||
return Chromosome(move(steps));
|
||||
return Chromosome(std::move(steps));
|
||||
}
|
||||
|
||||
ostream& phaser::operator<<(ostream& _stream, Chromosome const& _chromosome)
|
||||
|
||||
@@ -71,7 +71,7 @@ Population RandomAlgorithm::runNextRound(Population _population)
|
||||
size_t replacementCount = _population.individuals().size() - elitePopulation.individuals().size();
|
||||
|
||||
return
|
||||
move(elitePopulation) +
|
||||
std::move(elitePopulation) +
|
||||
Population::makeRandom(
|
||||
_population.fitnessMetric(),
|
||||
replacementCount,
|
||||
|
||||
@@ -44,7 +44,7 @@ function<Mutation> phaser::geneRandomisation(double _chance)
|
||||
gene
|
||||
);
|
||||
|
||||
return Chromosome(move(genes));
|
||||
return Chromosome(std::move(genes));
|
||||
};
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@ function<Mutation> phaser::geneDeletion(double _chance)
|
||||
if (!SimulationRNG::bernoulliTrial(_chance))
|
||||
genes.push_back(gene);
|
||||
|
||||
return Chromosome(move(genes));
|
||||
return Chromosome(std::move(genes));
|
||||
};
|
||||
}
|
||||
|
||||
@@ -77,7 +77,7 @@ function<Mutation> phaser::geneAddition(double _chance)
|
||||
genes.push_back(Chromosome::randomGene());
|
||||
}
|
||||
|
||||
return Chromosome(move(genes));
|
||||
return Chromosome(std::move(genes));
|
||||
};
|
||||
}
|
||||
|
||||
@@ -102,7 +102,7 @@ function<Mutation> phaser::mutationSequence(vector<function<Mutation>> _mutation
|
||||
{
|
||||
Chromosome mutatedChromosome = _chromosome;
|
||||
for (size_t i = 0; i < _mutations.size(); ++i)
|
||||
mutatedChromosome = _mutations[i](move(mutatedChromosome));
|
||||
mutatedChromosome = _mutations[i](std::move(mutatedChromosome));
|
||||
|
||||
return mutatedChromosome;
|
||||
};
|
||||
|
||||
@@ -107,7 +107,7 @@ class PairMosaicSelection: public PairSelection
|
||||
{
|
||||
public:
|
||||
explicit PairMosaicSelection(std::vector<std::tuple<size_t, size_t>> _pattern, double _selectionSize = 1.0):
|
||||
m_pattern(move(_pattern)),
|
||||
m_pattern(std::move(_pattern)),
|
||||
m_selectionSize(_selectionSize)
|
||||
{
|
||||
assert(m_pattern.size() > 0 || _selectionSize == 0.0);
|
||||
|
||||
+19
-19
@@ -239,8 +239,8 @@ unique_ptr<FitnessMetric> FitnessMetricFactory::build(
|
||||
{
|
||||
for (size_t i = 0; i < _programs.size(); ++i)
|
||||
metrics.push_back(make_unique<ProgramSize>(
|
||||
_programCaches[i] != nullptr ? optional<Program>{} : move(_programs[i]),
|
||||
move(_programCaches[i]),
|
||||
_programCaches[i] != nullptr ? optional<Program>{} : std::move(_programs[i]),
|
||||
std::move(_programCaches[i]),
|
||||
_weights,
|
||||
_options.chromosomeRepetitions
|
||||
));
|
||||
@@ -251,8 +251,8 @@ unique_ptr<FitnessMetric> FitnessMetricFactory::build(
|
||||
{
|
||||
for (size_t i = 0; i < _programs.size(); ++i)
|
||||
metrics.push_back(make_unique<RelativeProgramSize>(
|
||||
_programCaches[i] != nullptr ? optional<Program>{} : move(_programs[i]),
|
||||
move(_programCaches[i]),
|
||||
_programCaches[i] != nullptr ? optional<Program>{} : std::move(_programs[i]),
|
||||
std::move(_programCaches[i]),
|
||||
_options.relativeMetricScale,
|
||||
_weights,
|
||||
_options.chromosomeRepetitions
|
||||
@@ -266,13 +266,13 @@ unique_ptr<FitnessMetric> FitnessMetricFactory::build(
|
||||
switch (_options.metricAggregator)
|
||||
{
|
||||
case MetricAggregatorChoice::Average:
|
||||
return make_unique<FitnessMetricAverage>(move(metrics));
|
||||
return make_unique<FitnessMetricAverage>(std::move(metrics));
|
||||
case MetricAggregatorChoice::Sum:
|
||||
return make_unique<FitnessMetricSum>(move(metrics));
|
||||
return make_unique<FitnessMetricSum>(std::move(metrics));
|
||||
case MetricAggregatorChoice::Maximum:
|
||||
return make_unique<FitnessMetricMaximum>(move(metrics));
|
||||
return make_unique<FitnessMetricMaximum>(std::move(metrics));
|
||||
case MetricAggregatorChoice::Minimum:
|
||||
return make_unique<FitnessMetricMinimum>(move(metrics));
|
||||
return make_unique<FitnessMetricMinimum>(std::move(metrics));
|
||||
default:
|
||||
assertThrow(false, solidity::util::Exception, "Invalid MetricAggregatorChoice value.");
|
||||
}
|
||||
@@ -309,7 +309,7 @@ Population PopulationFactory::build(
|
||||
for (size_t populationSize: _options.randomPopulation)
|
||||
combinedSize += populationSize;
|
||||
|
||||
population = move(population) + buildRandom(
|
||||
population = std::move(population) + buildRandom(
|
||||
combinedSize,
|
||||
_options.minChromosomeLength,
|
||||
_options.maxChromosomeLength,
|
||||
@@ -317,7 +317,7 @@ Population PopulationFactory::build(
|
||||
);
|
||||
|
||||
for (string const& populationFilePath: _options.populationFromFile)
|
||||
population = move(population) + buildFromFile(populationFilePath, _fitnessMetric);
|
||||
population = std::move(population) + buildFromFile(populationFilePath, _fitnessMetric);
|
||||
|
||||
return population;
|
||||
}
|
||||
@@ -331,7 +331,7 @@ Population PopulationFactory::buildFromStrings(
|
||||
for (string const& geneSequence: _geneSequences)
|
||||
chromosomes.emplace_back(geneSequence);
|
||||
|
||||
return Population(move(_fitnessMetric), move(chromosomes));
|
||||
return Population(std::move(_fitnessMetric), std::move(chromosomes));
|
||||
}
|
||||
|
||||
Population PopulationFactory::buildRandom(
|
||||
@@ -342,7 +342,7 @@ Population PopulationFactory::buildRandom(
|
||||
)
|
||||
{
|
||||
return Population::makeRandom(
|
||||
move(_fitnessMetric),
|
||||
std::move(_fitnessMetric),
|
||||
_populationSize,
|
||||
_minChromosomeLength,
|
||||
_maxChromosomeLength
|
||||
@@ -354,7 +354,7 @@ Population PopulationFactory::buildFromFile(
|
||||
shared_ptr<FitnessMetric> _fitnessMetric
|
||||
)
|
||||
{
|
||||
return buildFromStrings(readLinesFromFile(_filePath), move(_fitnessMetric));
|
||||
return buildFromStrings(readLinesFromFile(_filePath), std::move(_fitnessMetric));
|
||||
}
|
||||
|
||||
ProgramCacheFactory::Options ProgramCacheFactory::Options::fromCommandLine(po::variables_map const& _arguments)
|
||||
@@ -371,7 +371,7 @@ vector<shared_ptr<ProgramCache>> ProgramCacheFactory::build(
|
||||
{
|
||||
vector<shared_ptr<ProgramCache>> programCaches;
|
||||
for (Program& program: _programs)
|
||||
programCaches.push_back(_options.programCacheEnabled ? make_shared<ProgramCache>(move(program)) : nullptr);
|
||||
programCaches.push_back(_options.programCacheEnabled ? make_shared<ProgramCache>(std::move(program)) : nullptr);
|
||||
|
||||
return programCaches;
|
||||
}
|
||||
@@ -400,7 +400,7 @@ vector<Program> ProgramFactory::build(Options const& _options)
|
||||
}
|
||||
|
||||
get<Program>(programOrErrors).optimise(Chromosome(_options.prefix).optimisationSteps());
|
||||
inputPrograms.push_back(move(get<Program>(programOrErrors)));
|
||||
inputPrograms.push_back(std::move(get<Program>(programOrErrors)));
|
||||
}
|
||||
|
||||
return inputPrograms;
|
||||
@@ -823,12 +823,12 @@ void Phaser::runPhaser(po::variables_map const& _arguments)
|
||||
programCaches,
|
||||
codeWeights
|
||||
);
|
||||
Population population = PopulationFactory::build(populationOptions, move(fitnessMetric));
|
||||
Population population = PopulationFactory::build(populationOptions, std::move(fitnessMetric));
|
||||
|
||||
if (_arguments["mode"].as<PhaserMode>() == PhaserMode::RunAlgorithm)
|
||||
runAlgorithm(_arguments, move(population), move(programCaches));
|
||||
runAlgorithm(_arguments, std::move(population), std::move(programCaches));
|
||||
else
|
||||
printOptimisedProgramsOrASTs(_arguments, population, move(programs), _arguments["mode"].as<PhaserMode>());
|
||||
printOptimisedProgramsOrASTs(_arguments, population, std::move(programs), _arguments["mode"].as<PhaserMode>());
|
||||
}
|
||||
|
||||
void Phaser::runAlgorithm(
|
||||
@@ -844,7 +844,7 @@ void Phaser::runAlgorithm(
|
||||
_population.individuals().size()
|
||||
);
|
||||
|
||||
AlgorithmRunner algorithmRunner(move(_population), move(_programCaches), buildAlgorithmRunnerOptions(_arguments), cout);
|
||||
AlgorithmRunner algorithmRunner(std::move(_population), std::move(_programCaches), buildAlgorithmRunnerOptions(_arguments), cout);
|
||||
algorithmRunner.run(*geneticAlgorithm);
|
||||
}
|
||||
|
||||
|
||||
@@ -68,7 +68,7 @@ Population Population::makeRandom(
|
||||
for (size_t i = 0; i < _size; ++i)
|
||||
chromosomes.push_back(Chromosome::makeRandom(_chromosomeLengthGenerator()));
|
||||
|
||||
return Population(move(_fitnessMetric), move(chromosomes));
|
||||
return Population(std::move(_fitnessMetric), std::move(chromosomes));
|
||||
}
|
||||
|
||||
Population Population::makeRandom(
|
||||
@@ -79,7 +79,7 @@ Population Population::makeRandom(
|
||||
)
|
||||
{
|
||||
return makeRandom(
|
||||
move(_fitnessMetric),
|
||||
std::move(_fitnessMetric),
|
||||
_size,
|
||||
std::bind(uniformChromosomeLength, _minChromosomeLength, _maxChromosomeLength)
|
||||
);
|
||||
@@ -112,7 +112,7 @@ Population Population::crossover(PairSelection const& _selection, function<Cross
|
||||
m_individuals[i].chromosome,
|
||||
m_individuals[j].chromosome
|
||||
);
|
||||
crossedIndividuals.emplace_back(move(childChromosome), *m_fitnessMetric);
|
||||
crossedIndividuals.emplace_back(std::move(childChromosome), *m_fitnessMetric);
|
||||
}
|
||||
|
||||
return Population(m_fitnessMetric, crossedIndividuals);
|
||||
@@ -132,8 +132,8 @@ tuple<Population, Population> Population::symmetricCrossoverWithRemainder(
|
||||
m_individuals[i].chromosome,
|
||||
m_individuals[j].chromosome
|
||||
);
|
||||
crossedIndividuals.emplace_back(move(get<0>(children)), *m_fitnessMetric);
|
||||
crossedIndividuals.emplace_back(move(get<1>(children)), *m_fitnessMetric);
|
||||
crossedIndividuals.emplace_back(std::move(get<0>(children)), *m_fitnessMetric);
|
||||
crossedIndividuals.emplace_back(std::move(get<1>(children)), *m_fitnessMetric);
|
||||
indexSelected[i] = true;
|
||||
indexSelected[j] = true;
|
||||
}
|
||||
@@ -159,7 +159,7 @@ Population operator+(Population _a, Population _b)
|
||||
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));
|
||||
return Population(_a.m_fitnessMetric, std::move(_a.m_individuals) + std::move(_b.m_individuals));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -193,7 +193,7 @@ vector<Individual> Population::chromosomesToIndividuals(
|
||||
{
|
||||
vector<Individual> individuals;
|
||||
for (auto& chromosome: _chromosomes)
|
||||
individuals.emplace_back(move(chromosome), _fitnessMetric);
|
||||
individuals.emplace_back(std::move(chromosome), _fitnessMetric);
|
||||
|
||||
return individuals;
|
||||
}
|
||||
|
||||
@@ -102,7 +102,7 @@ variant<Program, ErrorList> Program::load(CharStream& _sourceCode)
|
||||
|
||||
void Program::optimise(vector<string> const& _optimisationSteps)
|
||||
{
|
||||
m_ast = applyOptimisationSteps(m_dialect, m_nameDispenser, move(m_ast), _optimisationSteps);
|
||||
m_ast = applyOptimisationSteps(m_dialect, m_nameDispenser, std::move(m_ast), _optimisationSteps);
|
||||
}
|
||||
|
||||
ostream& phaser::operator<<(ostream& _stream, Program const& _program)
|
||||
@@ -153,7 +153,7 @@ variant<unique_ptr<Block>, ErrorList> Program::parseObject(Dialect const& _diale
|
||||
// to refactor ObjectParser and Object to use unique_ptr instead).
|
||||
auto astCopy = make_unique<Block>(get<Block>(ASTCopier{}(*selectedObject->code)));
|
||||
|
||||
return variant<unique_ptr<Block>, ErrorList>(move(astCopy));
|
||||
return variant<unique_ptr<Block>, ErrorList>(std::move(astCopy));
|
||||
}
|
||||
|
||||
variant<unique_ptr<AsmAnalysisInfo>, ErrorList> Program::analyzeAST(Dialect const& _dialect, Block const& _ast)
|
||||
@@ -168,7 +168,7 @@ variant<unique_ptr<AsmAnalysisInfo>, ErrorList> Program::analyzeAST(Dialect cons
|
||||
return errors;
|
||||
|
||||
assert(errorReporter.errors().empty());
|
||||
return variant<unique_ptr<AsmAnalysisInfo>, ErrorList>(move(analysisInfo));
|
||||
return variant<unique_ptr<AsmAnalysisInfo>, ErrorList>(std::move(analysisInfo));
|
||||
}
|
||||
|
||||
unique_ptr<Block> Program::disambiguateAST(
|
||||
|
||||
@@ -86,7 +86,7 @@ class MosaicSelection: public Selection
|
||||
{
|
||||
public:
|
||||
explicit MosaicSelection(std::vector<size_t> _pattern, double _selectionSize = 1.0):
|
||||
m_pattern(move(_pattern)),
|
||||
m_pattern(std::move(_pattern)),
|
||||
m_selectionSize(_selectionSize)
|
||||
{
|
||||
assert(m_pattern.size() > 0 || _selectionSize == 0.0);
|
||||
|
||||
Reference in New Issue
Block a user