From 6c0ee38fcb662c3a3ae7d652198ece7b94d61dd6 Mon Sep 17 00:00:00 2001 From: Laurent Perron Date: Wed, 30 Aug 2023 10:04:47 -0400 Subject: [PATCH] remove obsolete macro --- ortools/algorithms/knapsack_solver.cc | 6 ++- ortools/algorithms/knapsack_solver.h | 64 +++++++++++++++++++------ ortools/bop/bop_base.h | 6 ++- ortools/bop/bop_ls.h | 28 ++++++++--- ortools/bop/integral_solver.h | 7 ++- ortools/glop/basis_representation.h | 21 +++++--- ortools/glop/dual_edge_norms.h | 6 ++- ortools/glop/entering_variable.h | 6 ++- ortools/glop/initial_basis.h | 6 ++- ortools/glop/lp_solver.h | 6 ++- ortools/glop/lu_factorization.h | 6 ++- ortools/glop/primal_edge_norms.h | 6 ++- ortools/glop/rank_one_update.h | 6 ++- ortools/glop/reduced_costs.h | 6 ++- ortools/glop/revised_simplex.h | 12 +++-- ortools/glop/update_row.h | 6 ++- ortools/glop/variable_values.h | 6 ++- ortools/glop/variables_info.h | 6 ++- ortools/graph/assignment.h | 8 +++- ortools/graph/ebert_graph.h | 15 ++++-- ortools/graph/linear_assignment.h | 13 +++-- ortools/graph/linear_assignment_test.cc | 7 +-- ortools/graph/max_flow.h | 29 +++++++---- ortools/graph/min_cost_flow.h | 17 +++++-- ortools/graph/shortest_paths.cc | 13 +++-- ortools/graph/shortest_paths.h | 8 ++-- ortools/graph/topologicalsorter.h | 15 +++--- ortools/linear_solver/linear_solver.h | 40 ++++++++++++---- ortools/linear_solver/model_exporter.cc | 7 ++- ortools/lp_data/lp_data.h | 7 +-- ortools/lp_data/lp_decomposer.h | 6 ++- ortools/lp_data/matrix_scaler.h | 7 +-- ortools/lp_data/permutation.h | 6 ++- ortools/lp_data/sparse.h | 20 +++++--- ortools/lp_data/sparse_column.h | 7 ++- ortools/util/bitset.h | 16 +++++-- ortools/util/cached_log.h | 8 ++-- ortools/util/monoid_operation_tree.h | 7 +-- ortools/util/permutation.h | 20 ++++---- ortools/util/range_minimum_query.h | 11 +++-- ortools/util/range_query_function.cc | 23 ++++++--- ortools/util/running_stat.h | 13 +++-- ortools/util/stats.h | 23 ++++++--- ortools/util/time_limit.h | 7 +-- 44 files changed, 391 insertions(+), 172 deletions(-) diff --git a/ortools/algorithms/knapsack_solver.cc b/ortools/algorithms/knapsack_solver.cc index ba48e55510..d8fb3b810e 100644 --- a/ortools/algorithms/knapsack_solver.cc +++ b/ortools/algorithms/knapsack_solver.cc @@ -547,6 +547,10 @@ class KnapsackBruteForceSolver : public BaseKnapsackSolver { public: explicit KnapsackBruteForceSolver(const std::string& solver_name); + // This type is neither copyable nor movable. + KnapsackBruteForceSolver(const KnapsackBruteForceSolver&) = delete; + KnapsackBruteForceSolver& operator=(const KnapsackBruteForceSolver&) = delete; + // Initializes the solver and enters the problem to be solved. void Init(const std::vector& profits, const std::vector>& weights, @@ -566,8 +570,6 @@ class KnapsackBruteForceSolver : public BaseKnapsackSolver { int64_t capacity_; int64_t best_solution_profit_; uint32_t best_solution_; - - DISALLOW_COPY_AND_ASSIGN(KnapsackBruteForceSolver); }; KnapsackBruteForceSolver::KnapsackBruteForceSolver( diff --git a/ortools/algorithms/knapsack_solver.h b/ortools/algorithms/knapsack_solver.h index 082b3b9a0e..e1004f80d4 100644 --- a/ortools/algorithms/knapsack_solver.h +++ b/ortools/algorithms/knapsack_solver.h @@ -20,7 +20,6 @@ #include #include "absl/strings/string_view.h" -#include "ortools/base/macros.h" #include "ortools/util/time_limit.h" namespace operations_research { @@ -196,6 +195,13 @@ class KnapsackSolver { explicit KnapsackSolver(const std::string& solver_name); KnapsackSolver(SolverType solver_type, const std::string& solver_name); + +#ifndef SWIG + // This type is neither copyable nor movable. + KnapsackSolver(const KnapsackSolver&) = delete; + KnapsackSolver& operator=(const KnapsackSolver&) = delete; +#endif + virtual ~KnapsackSolver(); /** @@ -257,8 +263,6 @@ class KnapsackSolver { bool use_reduction_; double time_limit_seconds_; std::unique_ptr time_limit_; - - DISALLOW_COPY_AND_ASSIGN(KnapsackSolver); }; #if !defined(SWIG) @@ -336,6 +340,13 @@ class KnapsackSearchNode { public: KnapsackSearchNode(const KnapsackSearchNode* parent, const KnapsackAssignment& assignment); + +#ifndef SWIG + // This type is neither copyable nor movable. + KnapsackSearchNode(const KnapsackSearchNode&) = delete; + KnapsackSearchNode& operator=(const KnapsackSearchNode&) = delete; +#endif + int depth() const { return depth_; } const KnapsackSearchNode* parent() const { return parent_; } const KnapsackAssignment& assignment() const { return assignment_; } @@ -366,8 +377,6 @@ class KnapsackSearchNode { // 'next_item_id' field allows to avoid an O(number_of_items) scan to find // next item to select. This is done for free by the upper bound computation. int next_item_id_; - - DISALLOW_COPY_AND_ASSIGN(KnapsackSearchNode); }; // ----- KnapsackSearchPath ----- @@ -390,6 +399,13 @@ class KnapsackSearchPath { public: KnapsackSearchPath(const KnapsackSearchNode& from, const KnapsackSearchNode& to); + +#ifndef SWIG + // This type is neither copyable nor movable. + KnapsackSearchPath(const KnapsackSearchPath&) = delete; + KnapsackSearchPath& operator=(const KnapsackSearchPath&) = delete; +#endif + void Init(); const KnapsackSearchNode& from() const { return from_; } const KnapsackSearchNode& via() const { return *via_; } @@ -401,8 +417,6 @@ class KnapsackSearchPath { const KnapsackSearchNode& from_; const KnapsackSearchNode* via_; // Computed in 'Init'. const KnapsackSearchNode& to_; - - DISALLOW_COPY_AND_ASSIGN(KnapsackSearchPath); }; // ----- KnapsackState ----- @@ -411,6 +425,12 @@ class KnapsackState { public: KnapsackState(); +#ifndef SWIG + // This type is neither copyable nor movable. + KnapsackState(const KnapsackState&) = delete; + KnapsackState& operator=(const KnapsackState&) = delete; +#endif + // Initializes vectors with number_of_items set to false (i.e. not bound yet). void Init(int number_of_items); // Updates the state by applying or reverting a decision. @@ -429,8 +449,6 @@ class KnapsackState { // the absence (false) of item_i in the current solution. std::vector is_bound_; std::vector is_in_; - - DISALLOW_COPY_AND_ASSIGN(KnapsackState); }; // ----- KnapsackPropagator ----- @@ -444,6 +462,13 @@ class KnapsackState { class KnapsackPropagator { public: explicit KnapsackPropagator(const KnapsackState& state); + +#ifndef SWIG + // This type is neither copyable nor movable. + KnapsackPropagator(const KnapsackPropagator&) = delete; + KnapsackPropagator& operator=(const KnapsackPropagator&) = delete; +#endif + virtual ~KnapsackPropagator(); // Initializes data structure and then calls InitPropagator. @@ -503,8 +528,6 @@ class KnapsackPropagator { int64_t profit_lower_bound_; int64_t profit_upper_bound_; const KnapsackState& state_; - - DISALLOW_COPY_AND_ASSIGN(KnapsackPropagator); }; // ----- KnapsackCapacityPropagator ----- @@ -530,6 +553,14 @@ class KnapsackPropagator { class KnapsackCapacityPropagator : public KnapsackPropagator { public: KnapsackCapacityPropagator(const KnapsackState& state, int64_t capacity); + +#ifndef SWIG + // This type is neither copyable nor movable. + KnapsackCapacityPropagator(const KnapsackCapacityPropagator&) = delete; + KnapsackCapacityPropagator& operator=(const KnapsackCapacityPropagator&) = + delete; +#endif + ~KnapsackCapacityPropagator() override; void ComputeProfitBounds() override; int GetNextItemId() const override { return break_item_id_; } @@ -562,8 +593,6 @@ class KnapsackCapacityPropagator : public KnapsackPropagator { int break_item_id_; std::vector sorted_items_; int64_t profit_max_; - - DISALLOW_COPY_AND_ASSIGN(KnapsackCapacityPropagator); }; // ----- BaseKnapsackSolver ----- @@ -610,6 +639,13 @@ class BaseKnapsackSolver { class KnapsackGenericSolver : public BaseKnapsackSolver { public: explicit KnapsackGenericSolver(const std::string& solver_name); + +#ifndef SWIG + // This type is neither copyable nor movable. + KnapsackGenericSolver(const KnapsackGenericSolver&) = delete; + KnapsackGenericSolver& operator=(const KnapsackGenericSolver&) = delete; +#endif + ~KnapsackGenericSolver() override; // Initializes the solver and enters the problem to be solved. @@ -670,8 +706,6 @@ class KnapsackGenericSolver : public BaseKnapsackSolver { KnapsackState state_; int64_t best_solution_profit_; std::vector best_solution_; - - DISALLOW_COPY_AND_ASSIGN(KnapsackGenericSolver); }; #endif // SWIG } // namespace operations_research diff --git a/ortools/bop/bop_base.h b/ortools/bop/bop_base.h index 2ea62c8064..4f1c97f832 100644 --- a/ortools/bop/bop_base.h +++ b/ortools/bop/bop_base.h @@ -120,6 +120,10 @@ class ProblemState { public: explicit ProblemState(const sat::LinearBooleanProblem& problem); + // This type is neither copyable nor movable. + ProblemState(const ProblemState&) = delete; + ProblemState& operator=(const ProblemState&) = delete; + // Sets parameters, used for instance to get the tolerance, the gap limit... void SetParameters(const BopParameters& parameters) { parameters_ = parameters; @@ -242,8 +246,6 @@ class ProblemState { // Manage the set of the problem binary clauses (including the learned ones). sat::BinaryClauseManager binary_clause_manager_; - - DISALLOW_COPY_AND_ASSIGN(ProblemState); }; // This struct represents what has been learned on the problem state by diff --git a/ortools/bop/bop_ls.h b/ortools/bop/bop_ls.h index d3f4801829..5f281f775f 100644 --- a/ortools/bop/bop_ls.h +++ b/ortools/bop/bop_ls.h @@ -63,6 +63,10 @@ class SatWrapper { public: explicit SatWrapper(sat::SatSolver* sat_solver); + // This type is neither copyable nor movable. + SatWrapper(const SatWrapper&) = delete; + SatWrapper& operator=(const SatWrapper&) = delete; + // Returns the current state of the solver propagation trail. std::vector FullSatTrail() const; @@ -107,7 +111,6 @@ class SatWrapper { private: sat::SatSolver* sat_solver_; - DISALLOW_COPY_AND_ASSIGN(SatWrapper); }; // Forward declaration. @@ -281,6 +284,12 @@ class AssignmentAndConstraintFeasibilityMaintainer { explicit AssignmentAndConstraintFeasibilityMaintainer( const sat::LinearBooleanProblem& problem, absl::BitGenRef random); + // This type is neither copyable nor movable. + AssignmentAndConstraintFeasibilityMaintainer( + const AssignmentAndConstraintFeasibilityMaintainer&) = delete; + AssignmentAndConstraintFeasibilityMaintainer& operator=( + const AssignmentAndConstraintFeasibilityMaintainer&) = delete; + // When we construct the problem, we treat the objective as one constraint. // This is the index of this special "objective" constraint. static const ConstraintIndex kObjectiveConstraint; @@ -426,8 +435,6 @@ class AssignmentAndConstraintFeasibilityMaintainer { NonOrderedSetHasher constraint_set_hasher_; absl::flat_hash_map> hash_to_potential_repairs_; - - DISALLOW_COPY_AND_ASSIGN(AssignmentAndConstraintFeasibilityMaintainer); }; // This class is an utility class used to select which infeasible constraint to @@ -455,6 +462,11 @@ class OneFlipConstraintRepairer { const AssignmentAndConstraintFeasibilityMaintainer& maintainer, const sat::VariablesAssignment& sat_assignment); + // This type is neither copyable nor movable. + OneFlipConstraintRepairer(const OneFlipConstraintRepairer&) = delete; + OneFlipConstraintRepairer& operator=(const OneFlipConstraintRepairer&) = + delete; + static const ConstraintIndex kInvalidConstraint; static const TermIndex kInitTerm; static const TermIndex kInvalidTerm; @@ -506,8 +518,6 @@ class OneFlipConstraintRepairer { by_constraint_matrix_; const AssignmentAndConstraintFeasibilityMaintainer& maintainer_; const sat::VariablesAssignment& sat_assignment_; - - DISALLOW_COPY_AND_ASSIGN(OneFlipConstraintRepairer); }; // This class is used to iterate on all assignments that can be obtained by @@ -522,6 +532,12 @@ class LocalSearchAssignmentIterator { int max_num_broken_constraints, absl::BitGenRef random, SatWrapper* sat_wrapper); + + // This type is neither copyable nor movable. + LocalSearchAssignmentIterator(const LocalSearchAssignmentIterator&) = delete; + LocalSearchAssignmentIterator& operator=( + const LocalSearchAssignmentIterator&) = delete; + ~LocalSearchAssignmentIterator(); // Parameters of the LS algorithm. @@ -650,8 +666,6 @@ class LocalSearchAssignmentIterator { int64_t num_improvements_; int64_t num_improvements_by_one_flip_repairs_; int64_t num_inspected_one_flip_repairs_; - - DISALLOW_COPY_AND_ASSIGN(LocalSearchAssignmentIterator); }; } // namespace bop diff --git a/ortools/bop/integral_solver.h b/ortools/bop/integral_solver.h index b6453b75a7..16664c4fb8 100644 --- a/ortools/bop/integral_solver.h +++ b/ortools/bop/integral_solver.h @@ -31,6 +31,11 @@ namespace bop { class IntegralSolver { public: IntegralSolver(); + + // This type is neither copyable nor movable. + IntegralSolver(const IntegralSolver&) = delete; + IntegralSolver& operator=(const IntegralSolver&) = delete; + ~IntegralSolver() = default; // Sets the solver parameters. @@ -72,8 +77,6 @@ class IntegralSolver { glop::DenseRow variable_values_; glop::Fractional objective_value_; glop::Fractional best_bound_; - - DISALLOW_COPY_AND_ASSIGN(IntegralSolver); }; } // namespace bop } // namespace operations_research diff --git a/ortools/glop/basis_representation.h b/ortools/glop/basis_representation.h index 1637651ea6..acd75d1618 100644 --- a/ortools/glop/basis_representation.h +++ b/ortools/glop/basis_representation.h @@ -55,6 +55,11 @@ namespace glop { class EtaMatrix { public: EtaMatrix(ColIndex eta_col, const ScatteredColumn& direction); + + // This type is neither copyable nor movable. + EtaMatrix(const EtaMatrix&) = delete; + EtaMatrix& operator=(const EtaMatrix&) = delete; + virtual ~EtaMatrix(); // Solves the system y.E = c, 'c' beeing the initial value of 'y'. @@ -100,8 +105,6 @@ class EtaMatrix { // stored in eta_col_coefficient_ instead. DenseColumn eta_coeff_; SparseColumn sparse_eta_coeff_; - - DISALLOW_COPY_AND_ASSIGN(EtaMatrix); }; // An eta factorization corresponds to the product of k eta matrices, @@ -112,6 +115,11 @@ class EtaMatrix { class EtaFactorization { public: EtaFactorization(); + + // This type is neither copyable nor movable. + EtaFactorization(const EtaFactorization&) = delete; + EtaFactorization& operator=(const EtaFactorization&) = delete; + virtual ~EtaFactorization(); // Deletes all eta matrices. @@ -136,8 +144,6 @@ class EtaFactorization { private: std::vector eta_matrix_; - - DISALLOW_COPY_AND_ASSIGN(EtaFactorization); }; // A basis factorization is the product of an eta factorization and @@ -155,6 +161,11 @@ class BasisFactorization { public: BasisFactorization(const CompactSparseMatrix* compact_matrix, const RowToColMapping* basis); + + // This type is neither copyable nor movable. + BasisFactorization(const BasisFactorization&) = delete; + BasisFactorization& operator=(const BasisFactorization&) = delete; + virtual ~BasisFactorization(); // Sets the parameters for this component. @@ -382,8 +393,6 @@ class BasisFactorization { // mutable because the Solve() functions are const but need to update this. double last_factorization_deterministic_time_ = 0.0; mutable double deterministic_time_; - - DISALLOW_COPY_AND_ASSIGN(BasisFactorization); }; } // namespace glop diff --git a/ortools/glop/dual_edge_norms.h b/ortools/glop/dual_edge_norms.h index 03c56ea7b7..54f66a3929 100644 --- a/ortools/glop/dual_edge_norms.h +++ b/ortools/glop/dual_edge_norms.h @@ -51,6 +51,10 @@ class DualEdgeNorms { // Takes references to the linear program data we need. explicit DualEdgeNorms(const BasisFactorization& basis_factorization); + // This type is neither copyable nor movable. + DualEdgeNorms(const DualEdgeNorms&) = delete; + DualEdgeNorms& operator=(const DualEdgeNorms&) = delete; + // Clears, i.e. reset the object to its initial value. This will trigger a // full norm recomputation on the next GetEdgeSquaredNorms(). void Clear(); @@ -136,8 +140,6 @@ class DualEdgeNorms { // Whether we should recompute the norm from scratch. bool recompute_edge_squared_norms_; - - DISALLOW_COPY_AND_ASSIGN(DualEdgeNorms); }; } // namespace glop diff --git a/ortools/glop/entering_variable.h b/ortools/glop/entering_variable.h index 675640df3f..ec0f69999d 100644 --- a/ortools/glop/entering_variable.h +++ b/ortools/glop/entering_variable.h @@ -49,6 +49,10 @@ class EnteringVariable { EnteringVariable(const VariablesInfo& variables_info, absl::BitGenRef random, ReducedCosts* reduced_costs); + // This type is neither copyable nor movable. + EnteringVariable(const EnteringVariable&) = delete; + EnteringVariable& operator=(const EnteringVariable&) = delete; + // Dual optimization phase (i.e. phase II) ratio test. // Returns the index of the entering column given that we want to move along // the "update" row vector in the direction given by the sign of @@ -133,8 +137,6 @@ class EnteringVariable { // Counter for the deterministic time. int64_t num_operations_ = 0; - - DISALLOW_COPY_AND_ASSIGN(EnteringVariable); }; } // namespace glop diff --git a/ortools/glop/initial_basis.h b/ortools/glop/initial_basis.h index 2d59187393..dbdc6a98c5 100644 --- a/ortools/glop/initial_basis.h +++ b/ortools/glop/initial_basis.h @@ -51,6 +51,10 @@ class InitialBasis { const DenseRow& upper_bound, const VariableTypeRow& variable_type); + // This type is neither copyable nor movable. + InitialBasis(const InitialBasis&) = delete; + InitialBasis& operator=(const InitialBasis&) = delete; + // Completes the entries of the given basis that are equal to kInvalidCol with // one of the first num_cols columns of A using Bixby's algorithm. // @@ -127,8 +131,6 @@ class InitialBasis { const DenseRow& lower_bound_; const DenseRow& upper_bound_; const VariableTypeRow& variable_type_; - - DISALLOW_COPY_AND_ASSIGN(InitialBasis); }; } // namespace glop diff --git a/ortools/glop/lp_solver.h b/ortools/glop/lp_solver.h index 2c11ad42b1..1a1ceb1811 100644 --- a/ortools/glop/lp_solver.h +++ b/ortools/glop/lp_solver.h @@ -32,6 +32,10 @@ class LPSolver { public: LPSolver(); + // This type is neither copyable nor movable. + LPSolver(const LPSolver&) = delete; + LPSolver& operator=(const LPSolver&) = delete; + // Sets and gets the solver parameters. // See the proto for an extensive documentation. void SetParameters(const GlopParameters& parameters); @@ -299,8 +303,6 @@ class LPSolver { // The number of times Solve() was called. Used to number dump files. int num_solves_; - - DISALLOW_COPY_AND_ASSIGN(LPSolver); }; } // namespace glop diff --git a/ortools/glop/lu_factorization.h b/ortools/glop/lu_factorization.h index bd1b623ed5..10d4bedd59 100644 --- a/ortools/glop/lu_factorization.h +++ b/ortools/glop/lu_factorization.h @@ -38,6 +38,10 @@ class LuFactorization { public: LuFactorization(); + // This type is neither copyable nor movable. + LuFactorization(const LuFactorization&) = delete; + LuFactorization& operator=(const LuFactorization&) = delete; + // Returns true if the LuFactorization is a factorization of the identity // matrix. In this state, all the Solve() functions will work for any // vector dimension. @@ -298,8 +302,6 @@ class LuFactorization { // The class doing the Markowitz LU factorization. Markowitz markowitz_; - - DISALLOW_COPY_AND_ASSIGN(LuFactorization); }; } // namespace glop diff --git a/ortools/glop/primal_edge_norms.h b/ortools/glop/primal_edge_norms.h index 242941d127..501324177f 100644 --- a/ortools/glop/primal_edge_norms.h +++ b/ortools/glop/primal_edge_norms.h @@ -64,6 +64,10 @@ class PrimalEdgeNorms { const VariablesInfo& variables_info, const BasisFactorization& basis_factorization); + // This type is neither copyable nor movable. + PrimalEdgeNorms(const PrimalEdgeNorms&) = delete; + PrimalEdgeNorms& operator=(const PrimalEdgeNorms&) = delete; + // Clears, i.e. resets the object to its initial value. This will trigger // a recomputation for the next Get*() method call. void Clear(); @@ -225,8 +229,6 @@ class PrimalEdgeNorms { // Boolean(s) to set to false when the norms are changed outside of the // UpdateBeforeBasisPivot() function. std::vector watchers_; - - DISALLOW_COPY_AND_ASSIGN(PrimalEdgeNorms); }; } // namespace glop diff --git a/ortools/glop/rank_one_update.h b/ortools/glop/rank_one_update.h index 0057ab0960..c80363f6a4 100644 --- a/ortools/glop/rank_one_update.h +++ b/ortools/glop/rank_one_update.h @@ -138,6 +138,11 @@ class RankOneUpdateFactorization { // that switch between a sparse/dense version. RankOneUpdateFactorization() : hypersparse_ratio_(0.05) {} + // This type is neither copyable nor movable. + RankOneUpdateFactorization(const RankOneUpdateFactorization&) = delete; + RankOneUpdateFactorization& operator=(const RankOneUpdateFactorization&) = + delete; + // This is currently only visible for testing. void set_hypersparse_ratio(double value) { hypersparse_ratio_ = value; } @@ -242,7 +247,6 @@ class RankOneUpdateFactorization { double hypersparse_ratio_; EntryIndex num_entries_; std::vector elementary_matrices_; - DISALLOW_COPY_AND_ASSIGN(RankOneUpdateFactorization); }; } // namespace glop diff --git a/ortools/glop/reduced_costs.h b/ortools/glop/reduced_costs.h index b0996feb19..5b3cf82b39 100644 --- a/ortools/glop/reduced_costs.h +++ b/ortools/glop/reduced_costs.h @@ -58,6 +58,10 @@ class ReducedCosts { const BasisFactorization& basis_factorization, absl::BitGenRef random); + // This type is neither copyable nor movable. + ReducedCosts(const ReducedCosts&) = delete; + ReducedCosts& operator=(const ReducedCosts&) = delete; + // If this is true, then the caller must re-factorize the basis before the // next call to GetReducedCosts(). bool NeedsBasisRefactorization() const; @@ -286,8 +290,6 @@ class ReducedCosts { std::vector watchers_; double deterministic_time_ = 0.0; - - DISALLOW_COPY_AND_ASSIGN(ReducedCosts); }; // Maintains the list of dual infeasible positions and their associated prices. diff --git a/ortools/glop/revised_simplex.h b/ortools/glop/revised_simplex.h index d65f04dbde..5f2c6f7a82 100644 --- a/ortools/glop/revised_simplex.h +++ b/ortools/glop/revised_simplex.h @@ -96,7 +96,6 @@ #include #include "absl/random/bit_gen_ref.h" -#include "ortools/base/macros.h" #include "ortools/base/types.h" #include "ortools/glop/basis_representation.h" #include "ortools/glop/dual_edge_norms.h" @@ -126,6 +125,10 @@ class RevisedSimplex { public: RevisedSimplex(); + // This type is neither copyable nor movable. + RevisedSimplex(const RevisedSimplex&) = delete; + RevisedSimplex& operator=(const RevisedSimplex&) = delete; + // Sets or gets the algorithm parameters to be used on the next Solve(). void SetParameters(const GlopParameters& parameters); const GlopParameters& GetParameters() const { return parameters_; } @@ -826,8 +829,6 @@ class RevisedSimplex { // This is used by Polish(). DenseRow integrality_scale_; - - DISALLOW_COPY_AND_ASSIGN(RevisedSimplex); }; // Hides the details of the dictionary matrix implementation. In the future, @@ -848,6 +849,10 @@ class RevisedSimplexDictionary { ABSL_DIE_IF_NULL(revised_simplex)->ComputeDictionary(col_scales)), basis_vars_(ABSL_DIE_IF_NULL(revised_simplex)->GetBasisVector()) {} + // This type is neither copyable nor movable. + RevisedSimplexDictionary(const RevisedSimplexDictionary&) = delete; + RevisedSimplexDictionary& operator=(const RevisedSimplexDictionary&) = delete; + ConstIterator begin() const { return dictionary_.begin(); } ConstIterator end() const { return dictionary_.end(); } @@ -860,7 +865,6 @@ class RevisedSimplexDictionary { private: const RowMajorSparseMatrix dictionary_; const RowToColMapping basis_vars_; - DISALLOW_COPY_AND_ASSIGN(RevisedSimplexDictionary); }; // TODO(user): When a row-by-row generation of the dictionary is supported, diff --git a/ortools/glop/update_row.h b/ortools/glop/update_row.h index 59ba4036a5..7675a0d661 100644 --- a/ortools/glop/update_row.h +++ b/ortools/glop/update_row.h @@ -47,6 +47,10 @@ class UpdateRow { const VariablesInfo& variables_info, const RowToColMapping& basis, const BasisFactorization& basis_factorization); + // This type is neither copyable nor movable. + UpdateRow(const UpdateRow&) = delete; + UpdateRow& operator=(const UpdateRow&) = delete; + // Invalidates the current update row and unit_row_left_inverse so the next // call to ComputeUpdateRow() will recompute everything and not just return // right away. @@ -162,8 +166,6 @@ class UpdateRow { // Glop standard classes. GlopParameters parameters_; Stats stats_; - - DISALLOW_COPY_AND_ASSIGN(UpdateRow); }; } // namespace glop diff --git a/ortools/glop/variable_values.h b/ortools/glop/variable_values.h index bcd89b3117..2f8e2d85c5 100644 --- a/ortools/glop/variable_values.h +++ b/ortools/glop/variable_values.h @@ -52,6 +52,10 @@ class VariableValues { DualEdgeNorms* dual_edge_norms, DynamicMaximum* dual_prices); + // This type is neither copyable nor movable. + VariableValues(const VariableValues&) = delete; + VariableValues& operator=(const VariableValues&) = delete; + // Getters for the variable values. Fractional Get(ColIndex col) const { return variable_values_[col]; } const DenseRow& GetDenseRow() const { return variable_values_; } @@ -175,8 +179,6 @@ class VariableValues { // A temporary scattered column that is always reset to all zero after use. ScatteredColumn initially_all_zero_scratchpad_; - - DISALLOW_COPY_AND_ASSIGN(VariableValues); }; template diff --git a/ortools/glop/variables_info.h b/ortools/glop/variables_info.h index b6e39f61a7..e7f05dcd7a 100644 --- a/ortools/glop/variables_info.h +++ b/ortools/glop/variables_info.h @@ -57,6 +57,10 @@ class VariablesInfo { // Takes references to the linear program data we need. explicit VariablesInfo(const CompactSparseMatrix& matrix); + // This type is neither copyable nor movable. + VariablesInfo(const VariablesInfo&) = delete; + VariablesInfo& operator=(const VariablesInfo&) = delete; + // Updates the internal bounds and recomputes the variable types from the // bounds (this is the only function that changes them). // @@ -236,8 +240,6 @@ class VariablesInfo { // Whether we are between the calls TransformToDualPhaseIProblem() and // EndDualPhaseI(). bool in_dual_phase_one_ = false; - - DISALLOW_COPY_AND_ASSIGN(VariablesInfo); }; } // namespace glop diff --git a/ortools/graph/assignment.h b/ortools/graph/assignment.h index b4482f84f1..dc81d6a959 100644 --- a/ortools/graph/assignment.h +++ b/ortools/graph/assignment.h @@ -60,6 +60,13 @@ class SimpleLinearSumAssignment { // New node indices will be created lazily by AddArcWithCost(). SimpleLinearSumAssignment(); +#ifndef SWIG + // This type is neither copyable nor movable. + SimpleLinearSumAssignment(const SimpleLinearSumAssignment&) = delete; + SimpleLinearSumAssignment& operator=(const SimpleLinearSumAssignment&) = + delete; +#endif + // Adds an arc from a left node to a right node with a given cost. // * Node indices must be non-negative (>= 0). For a perfect // matching to exist on n nodes, the values taken by "left_node" @@ -122,7 +129,6 @@ class SimpleLinearSumAssignment { std::vector arc_cost_; std::vector assignment_arcs_; CostValue optimal_cost_; - DISALLOW_COPY_AND_ASSIGN(SimpleLinearSumAssignment); }; } // namespace operations_research diff --git a/ortools/graph/ebert_graph.h b/ortools/graph/ebert_graph.h index e58b189f1a..f5cbf904fb 100644 --- a/ortools/graph/ebert_graph.h +++ b/ortools/graph/ebert_graph.h @@ -177,7 +177,6 @@ #include "absl/strings/str_cat.h" #include "ortools/base/logging.h" -#include "ortools/base/macros.h" #include "ortools/base/types.h" #include "ortools/util/permutation.h" #include "ortools/util/zvector.h" @@ -579,6 +578,11 @@ class ForwardStaticGraph : ArrayIndexCycleHandler(&data[kFirstArc]), annotation_handler_(annotation_handler) {} + // This type is neither copyable nor movable. + CycleHandlerForAnnotatedArcs(const CycleHandlerForAnnotatedArcs&) = delete; + CycleHandlerForAnnotatedArcs& operator=( + const CycleHandlerForAnnotatedArcs&) = delete; + void SetTempFromIndex(ArcIndexType source) override { Base::SetTempFromIndex(source); annotation_handler_->SetTempFromIndex(source); @@ -597,8 +601,6 @@ class ForwardStaticGraph private: PermutationCycleHandler* annotation_handler_; - - DISALLOW_COPY_AND_ASSIGN(CycleHandlerForAnnotatedArcs); }; #endif // SWIG @@ -1056,6 +1058,11 @@ class EbertGraphBase head_temp_(kNilNode), tail_temp_(kNilNode) {} + // This type is neither copyable nor movable. + CycleHandlerForAnnotatedArcs(const CycleHandlerForAnnotatedArcs&) = delete; + CycleHandlerForAnnotatedArcs& operator=( + const CycleHandlerForAnnotatedArcs&) = delete; + void SetTempFromIndex(ArcIndexType source) override { if (annotation_handler_ != nullptr) { annotation_handler_->SetTempFromIndex(source); @@ -1100,8 +1107,6 @@ class EbertGraphBase DerivedGraph* graph_; NodeIndexType head_temp_; NodeIndexType tail_temp_; - - DISALLOW_COPY_AND_ASSIGN(CycleHandlerForAnnotatedArcs); }; #endif // SWIG diff --git a/ortools/graph/linear_assignment.h b/ortools/graph/linear_assignment.h index f8955c87ab..72e98e65cc 100644 --- a/ortools/graph/linear_assignment.h +++ b/ortools/graph/linear_assignment.h @@ -207,7 +207,6 @@ #include "absl/flags/declare.h" #include "absl/strings/str_format.h" #include "ortools/base/logging.h" -#include "ortools/base/macros.h" #include "ortools/base/types.h" #include "ortools/graph/ebert_graph.h" #include "ortools/util/permutation.h" @@ -239,6 +238,10 @@ class LinearSumAssignment { // us later via the SetGraph() method, below. LinearSumAssignment(NodeIndex num_left_nodes, ArcIndex num_arcs); + // This type is neither copyable nor movable. + LinearSumAssignment(const LinearSumAssignment&) = delete; + LinearSumAssignment& operator=(const LinearSumAssignment&) = delete; + ~LinearSumAssignment() {} // Sets the graph used by the LinearSumAssignment instance, for use @@ -949,8 +952,6 @@ class LinearSumAssignment { // Statistics giving the numbers of various operations the algorithm // has performed in the current iteration. Stats iteration_stats_; - - DISALLOW_COPY_AND_ASSIGN(LinearSumAssignment); }; // Implementation of out-of-line LinearSumAssignment template member @@ -1026,6 +1027,10 @@ class CostValueCycleHandler : public PermutationCycleHandler { explicit CostValueCycleHandler(std::vector* cost) : temp_(0), cost_(cost) {} + // This type is neither copyable nor movable. + CostValueCycleHandler(const CostValueCycleHandler&) = delete; + CostValueCycleHandler& operator=(const CostValueCycleHandler&) = delete; + void SetTempFromIndex(ArcIndexType source) override { temp_ = (*cost_)[source]; } @@ -1044,8 +1049,6 @@ class CostValueCycleHandler : public PermutationCycleHandler { private: CostValue temp_; std::vector* const cost_; - - DISALLOW_COPY_AND_ASSIGN(CostValueCycleHandler); }; // Logically this class should be defined inside OptimizeGraphLayout, diff --git a/ortools/graph/linear_assignment_test.cc b/ortools/graph/linear_assignment_test.cc index 9f4a908b85..e6387b4a8d 100644 --- a/ortools/graph/linear_assignment_test.cc +++ b/ortools/graph/linear_assignment_test.cc @@ -70,6 +70,10 @@ struct AssignmentProblemSetup { cycle_handler_scoped(assignment_scoped->ArcAnnotationCycleHandler()), cycle_handler(cycle_handler_scoped.get()) {} + // This type is neither copyable nor movable. + AssignmentProblemSetup(const AssignmentProblemSetup&) = delete; + AssignmentProblemSetup& operator=(const AssignmentProblemSetup&) = delete; + virtual ~AssignmentProblemSetup() { delete &assignment->Graph(); } void Finalize() { @@ -86,9 +90,6 @@ struct AssignmentProblemSetup { std::unique_ptr> cycle_handler_scoped; PermutationCycleHandler* cycle_handler; - - private: - DISALLOW_COPY_AND_ASSIGN(AssignmentProblemSetup); }; // A fixture template to collect the types of graphs on which we want to base diff --git a/ortools/graph/max_flow.h b/ortools/graph/max_flow.h index 865416d332..c62bbb9ed6 100644 --- a/ortools/graph/max_flow.h +++ b/ortools/graph/max_flow.h @@ -130,7 +130,6 @@ #include "absl/strings/string_view.h" #include "ortools/base/logging.h" -#include "ortools/base/macros.h" #include "ortools/base/types.h" #include "ortools/graph/ebert_graph.h" #include "ortools/graph/flow_problem.pb.h" @@ -156,6 +155,12 @@ class SimpleMaxFlow { // New node indices will be created lazily by AddArcWithCapacity(). SimpleMaxFlow(); +#ifndef SWIG + // This type is neither copyable nor movable. + SimpleMaxFlow(const SimpleMaxFlow&) = delete; + SimpleMaxFlow& operator=(const SimpleMaxFlow&) = delete; +#endif + // Adds a directed arc with the given capacity from tail to head. // * Node indices and capacity must be non-negative (>= 0). // * Self-looping and duplicate arcs are supported. @@ -243,8 +248,6 @@ class SimpleMaxFlow { typedef ::util::ReverseArcStaticGraph Graph; std::unique_ptr underlying_graph_; std::unique_ptr > underlying_max_flow_; - - DISALLOW_COPY_AND_ASSIGN(SimpleMaxFlow); }; // Specific but efficient priority queue implementation. The priority type must @@ -266,6 +269,14 @@ class PriorityQueueWithRestrictedPush { public: PriorityQueueWithRestrictedPush() : even_queue_(), odd_queue_() {} +#ifndef SWIG + // This type is neither copyable nor movable. + PriorityQueueWithRestrictedPush(const PriorityQueueWithRestrictedPush&) = + delete; + PriorityQueueWithRestrictedPush& operator=( + const PriorityQueueWithRestrictedPush&) = delete; +#endif + // Is the queue empty? bool IsEmpty() const; @@ -290,8 +301,6 @@ class PriorityQueueWithRestrictedPush { // both vectors are always sorted by increasing priority. std::vector > even_queue_; std::vector > odd_queue_; - - DISALLOW_COPY_AND_ASSIGN(PriorityQueueWithRestrictedPush); }; // We want an enum for the Status of a max flow run, and we want this @@ -333,6 +342,13 @@ class GenericMaxFlow : public MaxFlowStatusClass { // the memory of this class. source and sink must also be valid node of // graph. GenericMaxFlow(const Graph* graph, NodeIndex source, NodeIndex sink); + +#ifndef SWIG + // This type is neither copyable nor movable. + GenericMaxFlow(const GenericMaxFlow&) = delete; + GenericMaxFlow& operator=(const GenericMaxFlow&) = delete; +#endif + virtual ~GenericMaxFlow() {} // Returns the graph associated to the current object. @@ -640,9 +656,6 @@ class GenericMaxFlow : public MaxFlowStatusClass { // Statistics about this class. mutable StatsGroup stats_; - - private: - DISALLOW_COPY_AND_ASSIGN(GenericMaxFlow); }; #if !SWIG diff --git a/ortools/graph/min_cost_flow.h b/ortools/graph/min_cost_flow.h index fb67e4262d..be00abde43 100644 --- a/ortools/graph/min_cost_flow.h +++ b/ortools/graph/min_cost_flow.h @@ -176,7 +176,6 @@ #include "absl/strings/string_view.h" #include "ortools/base/logging.h" -#include "ortools/base/macros.h" #include "ortools/base/types.h" #include "ortools/graph/ebert_graph.h" #include "ortools/graph/graph.h" @@ -252,6 +251,12 @@ class SimpleMinCostFlow : public MinCostFlowBase { explicit SimpleMinCostFlow(NodeIndex reserve_num_nodes = 0, ArcIndex reserve_num_arcs = 0); +#ifndef SWIG + // This type is neither copyable nor movable. + SimpleMinCostFlow(const SimpleMinCostFlow&) = delete; + SimpleMinCostFlow& operator=(const SimpleMinCostFlow&) = delete; +#endif + // Adds a directed arc from tail to head to the underlying graph with // a given capacity and cost per unit of flow. // * Node indices and the capacity must be non-negative (>= 0). @@ -351,8 +356,6 @@ class SimpleMinCostFlow : public MinCostFlowBase { FlowQuantity maximum_flow_; bool scale_prices_ = true; - - DISALLOW_COPY_AND_ASSIGN(SimpleMinCostFlow); }; // Generic MinCostFlow that works with StarGraph and all the graphs handling @@ -389,6 +392,12 @@ class GenericMinCostFlow : public MinCostFlowBase { // initialize the memory of this class. explicit GenericMinCostFlow(const Graph* graph); +#ifndef SWIG + // This type is neither copyable nor movable. + GenericMinCostFlow(const GenericMinCostFlow&) = delete; + GenericMinCostFlow& operator=(const GenericMinCostFlow&) = delete; +#endif + // Returns the graph associated to the current object. const Graph* graph() const { return graph_; } @@ -660,8 +669,6 @@ class GenericMinCostFlow : public MinCostFlowBase { // Whether to scale prices, see SimpleMinCostFlow::SetPriceScaling(). bool scale_prices_ = true; - - DISALLOW_COPY_AND_ASSIGN(GenericMinCostFlow); }; #if !SWIG diff --git a/ortools/graph/shortest_paths.cc b/ortools/graph/shortest_paths.cc index 548af65fd2..f090539947 100644 --- a/ortools/graph/shortest_paths.cc +++ b/ortools/graph/shortest_paths.cc @@ -208,6 +208,10 @@ void PathTree::GetPath(NodeIndex from, NodeIndex to, class DistanceContainer : public PathContainerImpl { public: DistanceContainer() : reverse_sources_(), distances_() {} + + // This type is neither copyable nor movable. + DistanceContainer(const DistanceContainer&) = delete; + DistanceContainer& operator=(const DistanceContainer&) = delete; ~DistanceContainer() override {} void Initialize(const std::vector& sources, const std::vector& destinations, @@ -253,14 +257,17 @@ class DistanceContainer : public PathContainerImpl { } std::vector > distances_; - - DISALLOW_COPY_AND_ASSIGN(DistanceContainer); }; // Path container which stores explicit paths and distances between path nodes. class InMemoryCompactPathContainer : public DistanceContainer { public: InMemoryCompactPathContainer() : trees_(), destinations_() {} + + // This type is neither copyable nor movable. + InMemoryCompactPathContainer(const InMemoryCompactPathContainer&) = delete; + InMemoryCompactPathContainer& operator=(const InMemoryCompactPathContainer&) = + delete; ~InMemoryCompactPathContainer() override {} void Initialize(const std::vector& sources, const std::vector& destinations, @@ -291,8 +298,6 @@ class InMemoryCompactPathContainer : public DistanceContainer { private: std::vector trees_; std::vector destinations_; - - DISALLOW_COPY_AND_ASSIGN(InMemoryCompactPathContainer); }; // Priority queue node entry in the boundary of the Dijkstra algorithm. diff --git a/ortools/graph/shortest_paths.h b/ortools/graph/shortest_paths.h index 0c0f5f62d8..bde8a95aa0 100644 --- a/ortools/graph/shortest_paths.h +++ b/ortools/graph/shortest_paths.h @@ -68,7 +68,6 @@ #include #include "ortools/base/logging.h" -#include "ortools/base/macros.h" #include "ortools/base/types.h" #include "ortools/graph/ebert_graph.h" #include "ortools/graph/graph.h" @@ -104,6 +103,11 @@ class PathContainerImpl; class PathContainer { public: PathContainer(); + + // This type is neither copyable nor movable. + PathContainer(const PathContainer&) = delete; + PathContainer& operator=(const PathContainer&) = delete; + ~PathContainer(); // Returns the distance between node 'from' and node 'to' following the path @@ -153,8 +157,6 @@ class PathContainer { private: std::unique_ptr container_; - - DISALLOW_COPY_AND_ASSIGN(PathContainer); }; // Utility function which returns a vector containing all nodes of a graph. diff --git a/ortools/graph/topologicalsorter.h b/ortools/graph/topologicalsorter.h index bfc15f9469..57b81a49ec 100644 --- a/ortools/graph/topologicalsorter.h +++ b/ortools/graph/topologicalsorter.h @@ -45,7 +45,6 @@ #include "absl/strings/str_format.h" #include "ortools/base/container_logging.h" #include "ortools/base/logging.h" -#include "ortools/base/macros.h" #include "ortools/base/map_util.h" #include "ortools/base/status_builder.h" #include "ortools/base/stl_util.h" @@ -208,6 +207,11 @@ class DenseIntTopologicalSorterTpl { num_edges_(0), num_edges_added_since_last_duplicate_removal_(0) {} + // This type is neither copyable nor movable. + DenseIntTopologicalSorterTpl(const DenseIntTopologicalSorterTpl&) = delete; + DenseIntTopologicalSorterTpl& operator=(const DenseIntTopologicalSorterTpl&) = + delete; + // Performs in constant amortized time. Calling this will make all // node indices in [0 .. node_index] be valid node indices. If you // can avoid using AddNode(), you should! If you know the number of @@ -269,9 +273,6 @@ class DenseIntTopologicalSorterTpl { // RemoveDuplicates(). See the .cc. int num_edges_; // current total number of edges. int num_edges_added_since_last_duplicate_removal_; - - private: - DISALLOW_COPY_AND_ASSIGN(DenseIntTopologicalSorterTpl); }; extern template class DenseIntTopologicalSorterTpl; @@ -323,6 +324,10 @@ template coefficients_; // Constant term. double offset_; - - DISALLOW_COPY_AND_ASSIGN(MPObjective); }; /// The class for variables of a Mathematical Programming (MP) model. class MPVariable { public: +#ifndef SWIG + // This type is neither copyable nor movable. + MPVariable(const MPVariable&) = delete; + MPVariable& operator=(const MPVariable&) = delete; +#endif + /// Returns the name of the variable. const std::string& name() const { return name_; } @@ -1234,7 +1248,6 @@ class MPVariable { double reduced_cost_; int branching_priority_ = 0; MPSolverInterface* const interface_; - DISALLOW_COPY_AND_ASSIGN(MPVariable); }; /** @@ -1244,6 +1257,12 @@ class MPVariable { */ class MPConstraint { public: +#ifndef SWIG + // This type is neither copyable nor movable. + MPConstraint(const MPConstraint&) = delete; + MPConstraint& operator=(const MPConstraint&) = delete; +#endif + /// Returns the name of the constraint. const std::string& name() const { return name_; } @@ -1398,7 +1417,6 @@ class MPConstraint { double dual_value_; MPSolverInterface* const interface_; - DISALLOW_COPY_AND_ASSIGN(MPConstraint); }; /** @@ -1518,6 +1536,12 @@ class MPSolverParameters { /// The constructor sets all parameters to their default value. MPSolverParameters(); +#ifndef SWIG + // This type is neither copyable nor movable. + MPSolverParameters(const MPSolverParameters&) = delete; + MPSolverParameters& operator=(const MPSolverParameters&) = delete; +#endif + /// Sets a double parameter to a specific value. void SetDoubleParam(MPSolverParameters::DoubleParam param, double value); @@ -1563,8 +1587,6 @@ class MPSolverParameters { // solver's default value. Only parameters for which the wrapper // does not define a default value need such an indicator. bool lp_algorithm_is_default_; - - DISALLOW_COPY_AND_ASSIGN(MPSolverParameters); }; // Whether the given MPSolverResponseStatus (of a solve) would yield an RPC diff --git a/ortools/linear_solver/model_exporter.cc b/ortools/linear_solver/model_exporter.cc index 5d54389122..cf8804a4fe 100644 --- a/ortools/linear_solver/model_exporter.cc +++ b/ortools/linear_solver/model_exporter.cc @@ -82,6 +82,11 @@ void LineBreaker::Append(const std::string& s) { class MPModelProtoExporter { public: explicit MPModelProtoExporter(const MPModelProto& model); + + // This type is neither copyable nor movable. + MPModelProtoExporter(const MPModelProtoExporter&) = delete; + MPModelProtoExporter& operator=(const MPModelProtoExporter&) = delete; + bool ExportModelAsLpFormat(const MPModelExportOptions& options, std::string* output); bool ExportModelAsMpsFormat(const MPModelExportOptions& options, @@ -207,8 +212,6 @@ class MPModelProtoExporter { // Format for MPS file lines. std::unique_ptr> mps_header_format_; std::unique_ptr> mps_format_; - - DISALLOW_COPY_AND_ASSIGN(MPModelProtoExporter); }; } // namespace diff --git a/ortools/lp_data/lp_data.h b/ortools/lp_data/lp_data.h index 7576605614..138d12cc01 100644 --- a/ortools/lp_data/lp_data.h +++ b/ortools/lp_data/lp_data.h @@ -35,7 +35,6 @@ #include "absl/container/flat_hash_set.h" #include "ortools/base/hash.h" #include "ortools/base/logging.h" // for CHECK* -#include "ortools/base/macros.h" // for DISALLOW_COPY_AND_ASSIGN, NULL #include "ortools/glop/parameters.pb.h" #include "ortools/lp_data/lp_types.h" #include "ortools/lp_data/sparse.h" @@ -68,6 +67,10 @@ class LinearProgram { LinearProgram(); + // This type is neither copyable nor movable. + LinearProgram(const LinearProgram&) = delete; + LinearProgram& operator=(const LinearProgram&) = delete; + // Clears, i.e. reset the object to its initial value. void Clear(); @@ -650,8 +653,6 @@ class LinearProgram { friend void Scale(LinearProgram* lp, SparseMatrixScaler* scaler, GlopParameters::ScalingAlgorithm scaling_method); - - DISALLOW_COPY_AND_ASSIGN(LinearProgram); }; // -------------------------------------------------------- diff --git a/ortools/lp_data/lp_decomposer.h b/ortools/lp_data/lp_decomposer.h index 59477974f0..5b338ba41f 100644 --- a/ortools/lp_data/lp_decomposer.h +++ b/ortools/lp_data/lp_decomposer.h @@ -51,6 +51,10 @@ class LPDecomposer { public: LPDecomposer(); + // This type is neither copyable nor movable. + LPDecomposer(const LPDecomposer&) = delete; + LPDecomposer& operator=(const LPDecomposer&) = delete; + // Decomposes the problem into independent problems. // Note that a pointer is kept (no copy) on the linear_problem, so the problem // should not change during the life of the LPDecomposer object. @@ -84,8 +88,6 @@ class LPDecomposer { std::vector> clusters_; mutable absl::Mutex mutex_; - - DISALLOW_COPY_AND_ASSIGN(LPDecomposer); }; } // namespace glop diff --git a/ortools/lp_data/matrix_scaler.h b/ortools/lp_data/matrix_scaler.h index 6077e4e015..9511eef1e9 100644 --- a/ortools/lp_data/matrix_scaler.h +++ b/ortools/lp_data/matrix_scaler.h @@ -63,7 +63,6 @@ #include #include -#include "ortools/base/macros.h" #include "ortools/base/types.h" #include "ortools/glop/parameters.pb.h" #include "ortools/glop/revised_simplex.h" @@ -80,6 +79,10 @@ class SparseMatrixScaler { public: SparseMatrixScaler(); + // This type is neither copyable nor movable. + SparseMatrixScaler(const SparseMatrixScaler&) = delete; + SparseMatrixScaler& operator=(const SparseMatrixScaler&) = delete; + // Initializes the object with the SparseMatrix passed as argument. // The row and column scaling factors are all set to 1.0 (i.e. no scaling.) // In terms of matrices, R and C are set to identity matrices. @@ -184,8 +187,6 @@ class SparseMatrixScaler { // Array of scaling factors for each column. Indexed by column number. DenseRow col_scale_; - - DISALLOW_COPY_AND_ASSIGN(SparseMatrixScaler); }; } // namespace glop diff --git a/ortools/lp_data/permutation.h b/ortools/lp_data/permutation.h index 8671815e71..c7a181543b 100644 --- a/ortools/lp_data/permutation.h +++ b/ortools/lp_data/permutation.h @@ -47,6 +47,10 @@ class Permutation { explicit Permutation(IndexType size) : perm_(size.value(), IndexType(0)) {} + // This type is neither copyable nor movable. + Permutation(const Permutation&) = delete; + Permutation& operator=(const Permutation&) = delete; + IndexType size() const { return IndexType(perm_.size()); } bool empty() const { return perm_.empty(); } @@ -87,8 +91,6 @@ class Permutation { private: absl::StrongVector perm_; - - DISALLOW_COPY_AND_ASSIGN(Permutation); }; typedef Permutation RowPermutation; diff --git a/ortools/lp_data/sparse.h b/ortools/lp_data/sparse.h index 4e6b1f85da..86bbc11c2f 100644 --- a/ortools/lp_data/sparse.h +++ b/ortools/lp_data/sparse.h @@ -73,6 +73,11 @@ class SparseMatrix { #if (!defined(_MSC_VER) || _MSC_VER >= 1800) SparseMatrix( std::initializer_list> init_list); + + // This type is neither copyable nor movable. + SparseMatrix(const SparseMatrix&) = delete; + SparseMatrix& operator=(const SparseMatrix&) = delete; + #endif // Clears internal data structure, i.e. erases all the columns and set // the number of rows to zero. @@ -211,8 +216,6 @@ class SparseMatrix { // Number of rows. This is needed as sparse columns don't have a maximum // number of rows. RowIndex num_rows_; - - DISALLOW_COPY_AND_ASSIGN(SparseMatrix); }; // A matrix constructed from a list of already existing SparseColumn. This class @@ -339,6 +342,10 @@ class CompactSparseMatrix { PopulateFromMatrixView(MatrixView(matrix)); } + // This type is neither copyable nor movable. + CompactSparseMatrix(const CompactSparseMatrix&) = delete; + CompactSparseMatrix& operator=(const CompactSparseMatrix&) = delete; + // Creates a CompactSparseMatrix from the given MatrixView. The matrices are // the same, only the representation differ. Note that the entry order in // each column is preserved. @@ -506,9 +513,6 @@ class CompactSparseMatrix { StrictITIVector coefficients_; StrictITIVector rows_; StrictITIVector starts_; - - private: - DISALLOW_COPY_AND_ASSIGN(CompactSparseMatrix); }; inline Fractional CompactSparseMatrix::ConstView::ColumnScalarProduct( @@ -584,6 +588,10 @@ class TriangularMatrix : private CompactSparseMatrix { public: TriangularMatrix() : all_diagonal_coefficients_are_one_(true) {} + // This type is neither copyable nor movable. + TriangularMatrix(const TriangularMatrix&) = delete; + TriangularMatrix& operator=(const TriangularMatrix&) = delete; + // Only a subset of the functions from CompactSparseMatrix are exposed (note // the private inheritance). They are extended to deal with diagonal // coefficients properly. @@ -917,8 +925,6 @@ class TriangularMatrix : private CompactSparseMatrix { // TODO(user): Use this during the "normal" hyper-sparse solves so that // we can benefit from the pruned lower matrix there? StrictITIVector pruned_ends_; - - DISALLOW_COPY_AND_ASSIGN(TriangularMatrix); }; } // namespace glop diff --git a/ortools/lp_data/sparse_column.h b/ortools/lp_data/sparse_column.h index 33cdcc0bda..f164ece8e1 100644 --- a/ortools/lp_data/sparse_column.h +++ b/ortools/lp_data/sparse_column.h @@ -134,6 +134,11 @@ class RandomAccessSparseColumn { // Creates a RandomAccessSparseColumn. // Runs in O(num_rows). explicit RandomAccessSparseColumn(RowIndex num_rows); + + // This type is neither copyable nor movable. + RandomAccessSparseColumn(const RandomAccessSparseColumn&) = delete; + RandomAccessSparseColumn& operator=(const RandomAccessSparseColumn&) = delete; + virtual ~RandomAccessSparseColumn(); // Clears the column. @@ -189,8 +194,6 @@ class RandomAccessSparseColumn { // Stack to store changes. std::vector row_change_; - - DISALLOW_COPY_AND_ASSIGN(RandomAccessSparseColumn); }; } // namespace glop diff --git a/ortools/util/bitset.h b/ortools/util/bitset.h index 694fb4b37f..7bcc575862 100644 --- a/ortools/util/bitset.h +++ b/ortools/util/bitset.h @@ -23,7 +23,6 @@ #include #include "ortools/base/logging.h" -#include "ortools/base/macros.h" #include "ortools/base/types.h" namespace operations_research { @@ -433,6 +432,10 @@ class Bitset64 { : size_(Value(size) > 0 ? size : IndexType(0)), data_(BitLength64(Value(size_))) {} + // This type is neither copyable nor movable. + Bitset64(const Bitset64&) = delete; + Bitset64& operator=(const Bitset64&) = delete; + ConstView const_view() const { return ConstView(this); } // Returns how many bits this Bitset64 can hold. @@ -657,7 +660,6 @@ class Bitset64 { template friend class Bitset64; - DISALLOW_COPY_AND_ASSIGN(Bitset64); }; // Specialized version of Bitset64 that allows to query the last bit set more @@ -668,6 +670,10 @@ class BitQueue64 { explicit BitQueue64(int size) : size_(size), top_(-1), data_(BitLength64(size), 0) {} + // This type is neither copyable nor movable. + BitQueue64(const BitQueue64&) = delete; + BitQueue64& operator=(const BitQueue64&) = delete; + void IncreaseSize(int size) { CHECK_GE(size, size_); size_ = size; @@ -726,7 +732,6 @@ class BitQueue64 { int size_; int top_; std::vector data_; - DISALLOW_COPY_AND_ASSIGN(BitQueue64); }; // The specialization of Value() for IntType and int64_t. @@ -753,6 +758,10 @@ class SparseBitset { public: SparseBitset() {} explicit SparseBitset(IntegerType size) : bitset_(size) {} + + // This type is neither copyable nor movable. + SparseBitset(const SparseBitset&) = delete; + SparseBitset& operator=(const SparseBitset&) = delete; IntegerType size() const { return bitset_.size(); } void SparseClearAll() { for (const IntegerType i : to_clear_) bitset_.ClearBucket(i); @@ -825,7 +834,6 @@ class SparseBitset { private: Bitset64 bitset_; std::vector to_clear_; - DISALLOW_COPY_AND_ASSIGN(SparseBitset); }; } // namespace operations_research diff --git a/ortools/util/cached_log.h b/ortools/util/cached_log.h index f23ff22923..282fcc4bae 100644 --- a/ortools/util/cached_log.h +++ b/ortools/util/cached_log.h @@ -17,8 +17,6 @@ #include #include -#include "ortools/base/macros.h" - namespace operations_research { // This class is used when manipulating search space estimations. It // provides fast access to log of a domain size. @@ -29,6 +27,11 @@ namespace operations_research { class CachedLog { public: CachedLog(); + + // This type is neither copyable nor movable. + CachedLog(const CachedLog&) = delete; + CachedLog& operator=(const CachedLog&) = delete; + ~CachedLog(); // This method can only be called once, and with a cache_size > 0. @@ -39,7 +42,6 @@ class CachedLog { private: std::vector cache_; - DISALLOW_COPY_AND_ASSIGN(CachedLog); }; } // namespace operations_research diff --git a/ortools/util/monoid_operation_tree.h b/ortools/util/monoid_operation_tree.h index 7b2ef09577..b93af2407d 100644 --- a/ortools/util/monoid_operation_tree.h +++ b/ortools/util/monoid_operation_tree.h @@ -19,7 +19,6 @@ #include "absl/strings/str_format.h" #include "ortools/base/logging.h" -#include "ortools/base/macros.h" namespace operations_research { @@ -58,6 +57,10 @@ class MonoidOperationTree { // Constructs a MonoidOperationTree able to store 'size' operands. explicit MonoidOperationTree(int size); + // This type is neither copyable nor movable. + MonoidOperationTree(const MonoidOperationTree&) = delete; + MonoidOperationTree& operator=(const MonoidOperationTree&) = delete; + // Returns the root of the tree, containing the result of the operation. const T& result() const { return *result_; } @@ -132,8 +135,6 @@ class MonoidOperationTree { // A pointer to the root node T const* result_; - - DISALLOW_COPY_AND_ASSIGN(MonoidOperationTree); }; // --------------------------------------------------------------------- // diff --git a/ortools/util/permutation.h b/ortools/util/permutation.h index edabfdefb2..3836607e25 100644 --- a/ortools/util/permutation.h +++ b/ortools/util/permutation.h @@ -79,7 +79,6 @@ #define OR_TOOLS_UTIL_PERMUTATION_H_ #include "ortools/base/logging.h" -#include "ortools/base/macros.h" namespace operations_research { @@ -88,6 +87,10 @@ namespace operations_research { template class PermutationCycleHandler { public: + // This type is neither copyable nor movable. + PermutationCycleHandler(const PermutationCycleHandler&) = delete; + PermutationCycleHandler& operator=(const PermutationCycleHandler&) = delete; + // Sets the internal temporary storage from the given index in the // underlying container(s). virtual void SetTempFromIndex(IndexType source) = 0; @@ -128,9 +131,6 @@ class PermutationCycleHandler { protected: PermutationCycleHandler() {} - - private: - DISALLOW_COPY_AND_ASSIGN(PermutationCycleHandler); }; // A generic cycle handler class for the common case in which the @@ -143,6 +143,10 @@ class ArrayIndexCycleHandler : public PermutationCycleHandler { public: explicit ArrayIndexCycleHandler(DataType* data) : data_(data) {} + // This type is neither copyable nor movable. + ArrayIndexCycleHandler(const ArrayIndexCycleHandler&) = delete; + ArrayIndexCycleHandler& operator=(const ArrayIndexCycleHandler&) = delete; + void SetTempFromIndex(IndexType source) override { temp_ = data_[source]; } void SetIndexFromIndex(IndexType source, IndexType destination) const override { @@ -164,8 +168,6 @@ class ArrayIndexCycleHandler : public PermutationCycleHandler { // Temporary storage for the one extra element we need. DataType temp_; - - DISALLOW_COPY_AND_ASSIGN(ArrayIndexCycleHandler); }; // Note that this template is not implemented in an especially @@ -177,6 +179,10 @@ class PermutationApplier { explicit PermutationApplier(PermutationCycleHandler* cycle_handler) : cycle_handler_(cycle_handler) {} + // This type is neither copyable nor movable. + PermutationApplier(const PermutationApplier&) = delete; + PermutationApplier& operator=(const PermutationApplier&) = delete; + void Apply(IndexType permutation[], int permutation_start, int permutation_end) { for (IndexType current = permutation_start; current < permutation_end; @@ -205,8 +211,6 @@ class PermutationApplier { private: PermutationCycleHandler* cycle_handler_; - - DISALLOW_COPY_AND_ASSIGN(PermutationApplier); }; } // namespace operations_research #endif // OR_TOOLS_UTIL_PERMUTATION_H_ diff --git a/ortools/util/range_minimum_query.h b/ortools/util/range_minimum_query.h index 881de4796d..beb9ffb367 100644 --- a/ortools/util/range_minimum_query.h +++ b/ortools/util/range_minimum_query.h @@ -48,6 +48,10 @@ class RangeMinimumQuery { explicit RangeMinimumQuery(std::vector array); RangeMinimumQuery(std::vector array, Compare cmp); + // This type is neither copyable nor movable. + RangeMinimumQuery(const RangeMinimumQuery&) = delete; + RangeMinimumQuery& operator=(const RangeMinimumQuery&) = delete; + // Returns the minimum (w.r.t. Compare) arr[x], where x is contained in // [from, to). T GetMinimumFromRange(int from, int to) const; @@ -58,8 +62,6 @@ class RangeMinimumQuery { // cache_[k][i] = min(arr, i, i+2^k). std::vector> cache_; Compare cmp_; - - DISALLOW_COPY_AND_ASSIGN(RangeMinimumQuery); }; // RangeMinimumIndexQuery is similar to RangeMinimumQuery, but @@ -70,6 +72,10 @@ class RangeMinimumIndexQuery { explicit RangeMinimumIndexQuery(std::vector array); RangeMinimumIndexQuery(std::vector array, Compare cmp); + // This type is neither copyable nor movable. + RangeMinimumIndexQuery(const RangeMinimumIndexQuery&) = delete; + RangeMinimumIndexQuery& operator=(const RangeMinimumIndexQuery&) = delete; + // Returns an index idx from [from, to) such that arr[idx] is the minimum // value of arr over the interval [from, to). int GetMinimumIndexFromRange(int from, int to) const; @@ -86,7 +92,6 @@ class RangeMinimumIndexQuery { Compare cmp; } cmp_; const RangeMinimumQuery rmq_; - DISALLOW_COPY_AND_ASSIGN(RangeMinimumIndexQuery); }; // RangeMinimumQuery implementation diff --git a/ortools/util/range_query_function.cc b/ortools/util/range_query_function.cc index f2ac14e901..a257d565e1 100644 --- a/ortools/util/range_query_function.cc +++ b/ortools/util/range_query_function.cc @@ -20,7 +20,6 @@ #include #include "ortools/base/logging.h" -#include "ortools/base/macros.h" #include "ortools/base/types.h" #include "ortools/util/range_minimum_query.h" @@ -34,6 +33,11 @@ class LinearRangeIntToIntFunction : public RangeIntToIntFunction { std::function base_function) : base_function_(std::move(base_function)) {} + // This type is neither copyable nor movable. + LinearRangeIntToIntFunction(const LinearRangeIntToIntFunction&) = delete; + LinearRangeIntToIntFunction& operator=(const LinearRangeIntToIntFunction&) = + delete; + int64_t Query(int64_t argument) const override { return base_function_(argument); } @@ -87,8 +91,6 @@ class LinearRangeIntToIntFunction : public RangeIntToIntFunction { private: std::function base_function_; - - DISALLOW_COPY_AND_ASSIGN(LinearRangeIntToIntFunction); }; std::vector FunctionToVector(const std::function& f, @@ -117,6 +119,11 @@ class CachedRangeIntToIntFunction : public RangeIntToIntFunction { CHECK_LT(domain_start, domain_end); } + // This type is neither copyable nor movable. + CachedRangeIntToIntFunction(const CachedRangeIntToIntFunction&) = delete; + CachedRangeIntToIntFunction& operator=(const CachedRangeIntToIntFunction&) = + delete; + int64_t Query(int64_t argument) const override { DCHECK_LE(domain_start_, argument); DCHECK_LE(argument, domain_start_ + static_cast(array().size())); @@ -173,8 +180,6 @@ class CachedRangeIntToIntFunction : public RangeIntToIntFunction { const int64_t domain_start_; const RangeMinimumQuery> rmq_min_; const RangeMinimumQuery> rmq_max_; - - DISALLOW_COPY_AND_ASSIGN(CachedRangeIntToIntFunction); }; class CachedRangeMinMaxIndexFunction : public RangeMinMaxIndexFunction { @@ -188,6 +193,12 @@ class CachedRangeMinMaxIndexFunction : public RangeMinMaxIndexFunction { CHECK_LT(domain_start, domain_end); } + // This type is neither copyable nor movable. + CachedRangeMinMaxIndexFunction(const CachedRangeMinMaxIndexFunction&) = + delete; + CachedRangeMinMaxIndexFunction& operator=( + const CachedRangeMinMaxIndexFunction&) = delete; + inline int64_t RangeMinArgument(int64_t from, int64_t to) const override { DCHECK_LE(domain_start_, from); DCHECK_LT(from, to); @@ -210,8 +221,6 @@ class CachedRangeMinMaxIndexFunction : public RangeMinMaxIndexFunction { const int64_t domain_end_; const RangeMinimumIndexQuery> index_rmq_min_; const RangeMinimumIndexQuery> index_rmq_max_; - - DISALLOW_COPY_AND_ASSIGN(CachedRangeMinMaxIndexFunction); }; } // namespace diff --git a/ortools/util/running_stat.h b/ortools/util/running_stat.h index 803cb8ea57..20e18395e6 100644 --- a/ortools/util/running_stat.h +++ b/ortools/util/running_stat.h @@ -17,7 +17,6 @@ #include #include "ortools/base/logging.h" -#include "ortools/base/macros.h" namespace operations_research { @@ -29,6 +28,10 @@ class RunningAverage { // It must be positive (this is CHECKed). explicit RunningAverage(int window_size = 1); + // This type is neither copyable nor movable. + RunningAverage(const RunningAverage&) = delete; + RunningAverage& operator=(const RunningAverage&) = delete; + // Resets the class to the exact same state as if it was just constructed with // the given window size. void Reset(int window_size); @@ -57,8 +60,6 @@ class RunningAverage { double global_sum_; double local_sum_; std::deque values_; - - DISALLOW_COPY_AND_ASSIGN(RunningAverage); }; // Simple class to compute efficiently the maximum over a fixed size window @@ -69,6 +70,10 @@ class RunningMax { // Takes the size of the running window. The size must be positive. explicit RunningMax(int window_size); + // This type is neither copyable nor movable. + RunningMax(const RunningMax&) = delete; + RunningMax& operator=(const RunningMax&) = delete; + // Processes a new element from the stream. void Add(Number value); @@ -87,8 +92,6 @@ class RunningMax { // Index of the current maximum element. int max_index_; - - DISALLOW_COPY_AND_ASSIGN(RunningMax); }; // ################## Implementations below ##################### diff --git a/ortools/util/stats.h b/ortools/util/stats.h index a45b974ccf..5eca3a3665 100644 --- a/ortools/util/stats.h +++ b/ortools/util/stats.h @@ -74,7 +74,6 @@ #include "absl/strings/string_view.h" #include "absl/time/time.h" -#include "ortools/base/macros.h" #include "ortools/base/timer.h" namespace operations_research { @@ -134,6 +133,10 @@ class StatsGroup { explicit StatsGroup(absl::string_view name) : name_(name), stats_(), time_distributions_() {} + + // This type is neither copyable nor movable. + StatsGroup(const StatsGroup&) = delete; + StatsGroup& operator=(const StatsGroup&) = delete; ~StatsGroup(); // Registers a Stat, which will appear in the string returned by StatString(). @@ -162,8 +165,6 @@ class StatsGroup { PrintOrder print_order_ = SORT_BY_PRIORITY_THEN_VALUE; std::vector stats_; std::map time_distributions_; - - DISALLOW_COPY_AND_ASSIGN(StatsGroup); }; // Base class to track and compute statistics about the distribution of a @@ -315,6 +316,12 @@ class EnabledScopedTimeDistributionUpdater { : stat_(stat), also_update_(nullptr) { stat->StartTimer(); } + + // This type is neither copyable nor movable. + EnabledScopedTimeDistributionUpdater( + const EnabledScopedTimeDistributionUpdater&) = delete; + EnabledScopedTimeDistributionUpdater& operator=( + const EnabledScopedTimeDistributionUpdater&) = delete; ~EnabledScopedTimeDistributionUpdater() { const double cycles = stat_->StopTimerAndAddElapsedTime(); if (also_update_ != nullptr) { @@ -336,16 +343,18 @@ class EnabledScopedTimeDistributionUpdater { private: TimeDistribution* stat_; TimeDistribution* also_update_; - DISALLOW_COPY_AND_ASSIGN(EnabledScopedTimeDistributionUpdater); }; class DisabledScopedTimeDistributionUpdater { public: explicit DisabledScopedTimeDistributionUpdater(TimeDistribution* stat) {} - void AlsoUpdate(TimeDistribution* also_update) {} - private: - DISALLOW_COPY_AND_ASSIGN(DisabledScopedTimeDistributionUpdater); + // This type is neither copyable nor movable. + DisabledScopedTimeDistributionUpdater( + const DisabledScopedTimeDistributionUpdater&) = delete; + DisabledScopedTimeDistributionUpdater& operator=( + const DisabledScopedTimeDistributionUpdater&) = delete; + void AlsoUpdate(TimeDistribution* also_update) {} }; class DisabledScopedInstructionCounter { diff --git a/ortools/util/time_limit.h b/ortools/util/time_limit.h index b74c99d0d5..dc2fa6548e 100644 --- a/ortools/util/time_limit.h +++ b/ortools/util/time_limit.h @@ -25,7 +25,6 @@ #include "absl/flags/declare.h" #include "absl/synchronization/mutex.h" #include "absl/time/clock.h" -#include "ortools/base/macros.h" #include "ortools/base/timer.h" #include "ortools/base/types.h" #include "ortools/util/running_stat.h" @@ -392,6 +391,10 @@ class NestedTimeLimit { NestedTimeLimit(TimeLimit* base_time_limit, double limit_in_seconds, double deterministic_limit); + // This type is neither copyable nor movable. + NestedTimeLimit(const NestedTimeLimit&) = delete; + NestedTimeLimit& operator=(const NestedTimeLimit&) = delete; + /** * Updates elapsed deterministic time in the base time limit object. */ @@ -423,8 +426,6 @@ class NestedTimeLimit { private: TimeLimit* const base_time_limit_; TimeLimit time_limit_; - - DISALLOW_COPY_AND_ASSIGN(NestedTimeLimit); }; // ################## Implementations below #####################