diff --git a/mex/sources/bytecode/Interpreter.cc b/mex/sources/bytecode/Interpreter.cc index 2753c116de8b7fd79770afae4ac887061632e3a5..32515f83d525671ab13d4b957f21674572819ff6 100644 --- a/mex/sources/bytecode/Interpreter.cc +++ b/mex/sources/bytecode/Interpreter.cc @@ -660,24 +660,23 @@ Interpreter::check_for_controlled_exo_validity(const vector<s_plan>& sconstraine vector<int> endogenous {evaluator.getCurrentBlockVariables()}; for (auto& it : sconstrained_extended_path) { - if (find(endogenous.begin(), endogenous.end(), it.exo_num) != endogenous.end() - && find(exogenous.begin(), exogenous.end(), it.var_num) == exogenous.end()) + if (ranges::find(endogenous, it.exo_num) != endogenous.end() + && ranges::find(exogenous, it.var_num) == exogenous.end()) throw FatalException {"\nThe conditional forecast involving as constrained variable " + symbol_table.getName(SymbolType::endogenous, it.exo_num) + " and as endogenized exogenous " + symbol_table.getName(SymbolType::exogenous, it.var_num) + " that do not appear in block=" + to_string(block_num + 1) + ")\nYou should not use block in model options"}; - else if (find(endogenous.begin(), endogenous.end(), it.exo_num) != endogenous.end() - && find(exogenous.begin(), exogenous.end(), it.var_num) != exogenous.end() + else if (ranges::find(endogenous, it.exo_num) != endogenous.end() + && ranges::find(exogenous, it.var_num) != exogenous.end() && (type == BlockSimulationType::evaluateForward || type == BlockSimulationType::evaluateBackward)) throw FatalException {"\nThe conditional forecast cannot be implemented for the block=" + to_string(block_num + 1) + ") that has to be evaluated instead to be solved\nYou should not " "use block in model options"}; - else if (find(previous_block_exogenous.begin(), previous_block_exogenous.end(), it.var_num) - != previous_block_exogenous.end()) + else if (ranges::find(previous_block_exogenous, it.var_num) != previous_block_exogenous.end()) throw FatalException { "\nThe conditional forecast involves in the block " + to_string(block_num + 1) + " the endogenized exogenous " diff --git a/mex/sources/libkorder/tl/equivalence.cc b/mex/sources/libkorder/tl/equivalence.cc index 3b348b4ced54f3f0c1670cb33dd05a28ac130a73..3b560bfd3f8213585a4ec927a60a92001719594b 100644 --- a/mex/sources/libkorder/tl/equivalence.cc +++ b/mex/sources/libkorder/tl/equivalence.cc @@ -22,6 +22,7 @@ #include "permutation.hh" #include "tl_exception.hh" +#include <algorithm> #include <iostream> #include <numeric> @@ -85,14 +86,7 @@ OrdSequence::add(const OrdSequence& s) bool OrdSequence::has(int i) const { - auto vit = data.begin(); - while (vit != data.end()) - { - if (*vit == i) - return true; - ++vit; - } - return false; + return std::ranges::find(data, i) != data.end(); } /* Return an average of the class. */