From 8da8b100cc62bbb83d09692c23709b44edd0205a Mon Sep 17 00:00:00 2001 From: Mikael Zayenz Lagerkvist Date: Tue, 3 Nov 2026 23:39:36 +0100 Subject: [PATCH 1/4] Make the shallow handles trivially copyable Group, PropagatorGroup, BrancherGroup, Pos, LocalHandle, AFC and its subclasses, the variables, VarArray and its subclasses, and ViewArray lose hand-written copy members and empty destructors that only copied members, so the compiler's trivial ones apply. Home keeps its Space& member, gets a defaulted copy constructor, and is no longer copy-assignable; Space is no longer copy-assignable either. VarArray and ViewArray assignment now returns a non-const reference. static_asserts in test/array.cpp keep the handles trivially copyable. AllowedTypes now lists only Float::ScaleView, whose FloatVal member is still non-trivial. Zdev-Change-Id: Zf784ff784715e79585c52d1beeea68adf93a36f794a04944e8431bf8303b4bcf --- .clang-tidy | 2 +- changelog.in | 24 +++++++++++ docs/code-style.md | 25 +++++++----- gecode/float.hh | 8 +--- gecode/float/array.hpp | 4 -- gecode/float/branch/afc.hpp | 9 ----- gecode/float/var/float.hpp | 3 -- gecode/int.hh | 16 ++------ gecode/int/array.hpp | 8 ---- gecode/int/branch/afc.hpp | 18 --------- gecode/int/var/bool.hpp | 3 -- gecode/int/var/int.hpp | 3 -- gecode/kernel/branch/afc.hpp | 17 -------- gecode/kernel/branch/view.hpp | 5 --- gecode/kernel/core.hpp | 76 +++-------------------------------- gecode/kernel/data/array.hpp | 40 +++--------------- gecode/set.hh | 8 +--- gecode/set/array.hpp | 4 -- gecode/set/branch/afc.hpp | 9 ----- gecode/set/var/set.hpp | 4 -- test/array.cpp | 50 +++++++++++++++++++++++ 21 files changed, 110 insertions(+), 226 deletions(-) diff --git a/.clang-tidy b/.clang-tidy index 54744f3955..469685e6f4 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -42,7 +42,7 @@ CheckOptions: bugprone-unused-return-value.AllowCastToVoid: true # Shallow handles stay passed by value: a copy duplicates a few pointers or # ids, with no reference count or allocation. See docs/code-style.md. - performance-unnecessary-value-param.AllowedTypes: '^Gecode::(Home|Group|PropagatorGroup|BrancherGroup|Pos|Reify)$;^Gecode::(Int|Bool|Set|Float)Var$;^Gecode::(Int|Bool|Set|Float)VarArray$;^Gecode::(VarArray|ViewArray)(<.*>)?$;^Gecode::(OpenIntVarList|OpenBoolVarList|OpenVarList|OpenViewList)(<.*>)?$;^Gecode::(VarImpView|DerivedView|ConstView)(<.*>)?$;^Gecode::(Int|Set|Float)::[A-Za-z]*View(<.*>)?$;^Gecode::.*::VarType$' + performance-unnecessary-value-param.AllowedTypes: '^Gecode::Float::ScaleView$' readability-identifier-naming.FunctionCase: lower_case readability-identifier-naming.MethodCase: lower_case readability-identifier-naming.VariableCase: lower_case diff --git a/changelog.in b/changelog.in index 97d69ef0b3..ab16c3f7c9 100644 --- a/changelog.in +++ b/changelog.in @@ -76,6 +76,30 @@ Date: unreleased This release contains breaking changes. See the entries below for the changes downstream code needs. +[ENTRY] +Module: kernel +What: change +Rank: major +[DESCRIPTION] +Make Home, the groups, Pos, Reify, LocalHandle, the variables, the variable +arrays, ViewArray, the open variable and view lists, and AFC with its +subclasses trivially copyable. Their copy constructors and copy assignments +are now implicit or defaulted, and the AFC classes and LocalHandle no longer +declare a destructor. Copies behave as before, but the ABI changes, and the +compiler may now pass these types in registers. +[MORE] +VarArray::operator= and ViewArray::operator= now return a non-const +reference. + +[ENTRY] +Module: kernel +What: removed +Rank: major +[DESCRIPTION] +Delete the copy assignment of Home and of Space. Assigning one Home to +another copy-assigned the whole Space that the home refers to. A Home never +changes its space; construct a new Home instead. To copy a Space, clone it. + [ENTRY] Module: support What: removed diff --git a/docs/code-style.md b/docs/code-style.md index 996dbf62b9..6f3a5308f7 100644 --- a/docs/code-style.md +++ b/docs/code-style.md @@ -123,16 +123,21 @@ and the type has a real move constructor, such as `std::function`, `std::string`, `std::vector`, or a branching configuration, take it by value and `std::move` it into place instead. -The check's `AllowedTypes` keeps Gecode's shallow handles passed by value: -`Home`, the groups, `Pos`, `Reify`, the variables (`IntVar` and so on), the -variable arrays and `ViewArray`, the open variable and view lists, the views, -and `View::VarType`. Copying one copies a few pointers or ids, with no -reference count or allocation, and Gecode code relies on their value -semantics. Owned and reference-counted types are not exempt: `SharedHandle` -types such as `IntSet`, `TupleSet`, `DFA`, `Rnd`, `Action`, and `CHB`, -`SharedArray`, the `*Args` arrays, `REG`, strings, and callbacks. Their copies -touch a reference count or allocate, so they follow the rule above. `FloatVal` -is not exempt either: it is two doubles, not a handle. +Gecode's shallow handles are trivially copyable, so the check never reports +them: `Home`, the groups, `Pos`, `Reify`, the variables (`IntVar` and so +on), the variable arrays and `ViewArray`, the open variable and view lists, +`LocalHandle`, `AFC`, and the views. Copying one copies a few pointers or ids, +with no reference count or allocation, and Gecode code relies on their value +semantics. Keep them so: define no copy member, move member, or destructor +for a handle that only copies its members, or default it on its first +declaration. `test/array.cpp` asserts the property. The check's +`AllowedTypes` lists only `Float::ScaleView`, a view that is not trivially +copyable because its `FloatVal` member is not. Owned and reference-counted +types are not exempt: `SharedHandle` types such as `IntSet`, `TupleSet`, +`DFA`, `Rnd`, `Action`, and `CHB`, `SharedArray`, the `*Args` arrays, `REG`, +strings, and callbacks. Their copies touch a reference count or allocate, so +they follow the rule above. `FloatVal` is not exempt either: it is two +doubles, not a handle. Other performance checks need focused review: `performance-enum-size` changes layouts and ABI, and `performance-no-int-to-ptr` conflicts with deliberate diff --git a/gecode/float.hh b/gecode/float.hh index 2bac7c288c..75f539b497 100644 --- a/gecode/float.hh +++ b/gecode/float.hh @@ -876,7 +876,7 @@ namespace Gecode { /// Default constructor FloatVar(void); /// Initialize from float variable \a y - FloatVar(const FloatVar& y); + FloatVar(const FloatVar& y) = default; /// Initialize from float view \a y FloatVar(const Float::FloatView& y); /** @@ -1031,7 +1031,7 @@ namespace Gecode { /// Allocate array for \a n float variables (variables are uninitialized) FloatVarArray(Space& home, int n); /// Initialize from float variable array \a a (share elements) - FloatVarArray(const FloatVarArray& a); + FloatVarArray(const FloatVarArray& a) = default; /// Initialize from float variable argument array \a a (copy elements) FloatVarArray(Space& home, const FloatVarArgs& a); /** @@ -1452,10 +1452,6 @@ namespace Gecode { * */ FloatAFC(void); - /// Copy constructor - FloatAFC(const FloatAFC& a); - /// Assignment operator - FloatAFC& operator=(const FloatAFC& a); /** * \brief Initialize for float variables \a x and decay factor \a d * diff --git a/gecode/float/array.hpp b/gecode/float/array.hpp index 553855e2c0..cbb9f92aa5 100644 --- a/gecode/float/array.hpp +++ b/gecode/float/array.hpp @@ -104,10 +104,6 @@ namespace Gecode { FloatVarArray::FloatVarArray(Space& home, int n) : VarArray(home, n) {} - forceinline - FloatVarArray::FloatVarArray(const FloatVarArray& a) - : VarArray(a) {} - forceinline FloatVarArray::FloatVarArray(Space& home, const FloatVarArgs& a) : VarArray(home, a) {} diff --git a/gecode/float/branch/afc.hpp b/gecode/float/branch/afc.hpp index 4d3d20fd83..9a105cb9c5 100644 --- a/gecode/float/branch/afc.hpp +++ b/gecode/float/branch/afc.hpp @@ -35,15 +35,6 @@ namespace Gecode { forceinline FloatAFC::FloatAFC(void) {} - forceinline - FloatAFC::FloatAFC(const FloatAFC& a) - : AFC(a) {} - - forceinline FloatAFC& - FloatAFC::operator=(const FloatAFC& a) { - return static_cast(AFC::operator=(a)); - } - forceinline FloatAFC::FloatAFC(Home home, const FloatVarArgs& x, double d, bool share) { AFC::init(home, x, d, share); diff --git a/gecode/float/var/float.hpp b/gecode/float/var/float.hpp index 71cc8d416e..e7124b56ad 100644 --- a/gecode/float/var/float.hpp +++ b/gecode/float/var/float.hpp @@ -42,9 +42,6 @@ namespace Gecode { forceinline FloatVar::FloatVar(void) {} forceinline - FloatVar::FloatVar(const FloatVar& y) - : VarImpVar(y.varimp()) {} - forceinline FloatVar::FloatVar(const Float::FloatView& y) : VarImpVar(y.varimp()) {} diff --git a/gecode/int.hh b/gecode/int.hh index 25f3ced59d..ae2cfd7bfd 100644 --- a/gecode/int.hh +++ b/gecode/int.hh @@ -410,7 +410,7 @@ namespace Gecode { /// Default constructor IntVar(void); /// Initialize from integer variable \a y - IntVar(const IntVar& y); + IntVar(const IntVar& y) = default; /// Initialize from integer view \a y IntVar(const Int::IntView& y); /** @@ -548,7 +548,7 @@ namespace Gecode { /// Default constructor BoolVar(void); /// Initialize from Boolean variable \a y - BoolVar(const BoolVar& y); + BoolVar(const BoolVar& y) = default; /// Initialize from Boolean view \a y BoolVar(const Int::BoolView& y); /** @@ -795,7 +795,7 @@ namespace Gecode { /// Allocate array for \a n integer variables (variables are uninitialized) IntVarArray(Space& home, int n); /// Initialize from integer variable array \a a (share elements) - IntVarArray(const IntVarArray& a); + IntVarArray(const IntVarArray& a) = default; /// Initialize from integer variable argument array \a a (copy elements) IntVarArray(Space& home, const IntVarArgs& a); /** @@ -843,7 +843,7 @@ namespace Gecode { /// Allocate array for \a n Boolean variables (variables are uninitialized) BoolVarArray(Space& home, int n); /// Initialize from Boolean variable array \a a (share elements) - BoolVarArray(const BoolVarArray& a); + BoolVarArray(const BoolVarArray& a) = default; /// Initialize from Boolean variable argument array \a a (copy elements) BoolVarArray(Space& home, const BoolVarArgs& a); /** @@ -4925,10 +4925,6 @@ namespace Gecode { * */ IntAFC(void); - /// Copy constructor - IntAFC(const IntAFC& a); - /// Assignment operator - IntAFC& operator=(const IntAFC& a); /** * \brief Initialize for integer variables \a x and decay factor \a d * @@ -4965,10 +4961,6 @@ namespace Gecode { * */ BoolAFC(void); - /// Copy constructor - BoolAFC(const BoolAFC& a); - /// Assignment operator - BoolAFC& operator=(const BoolAFC& a); /** * \brief Initialize for Boolean variables \a x and decay factor \a d * diff --git a/gecode/int/array.hpp b/gecode/int/array.hpp index 4ac43b2fcb..34ad4987d4 100644 --- a/gecode/int/array.hpp +++ b/gecode/int/array.hpp @@ -144,10 +144,6 @@ namespace Gecode { IntVarArray::IntVarArray(Space& home, int n) : VarArray(home, n) {} - forceinline - IntVarArray::IntVarArray(const IntVarArray& a) - : VarArray(a) {} - forceinline IntVarArray::IntVarArray(Space& home, const IntVarArgs& a) : VarArray(home, a) {} @@ -159,10 +155,6 @@ namespace Gecode { BoolVarArray::BoolVarArray(Space& home, int n) : VarArray(home, n) {} - forceinline - BoolVarArray::BoolVarArray(const BoolVarArray& a) - : VarArray(a) {} - forceinline BoolVarArray::BoolVarArray(Space& home, const BoolVarArgs& a) : VarArray(home, a) {} diff --git a/gecode/int/branch/afc.hpp b/gecode/int/branch/afc.hpp index ebba8dcc09..7c00fbe441 100644 --- a/gecode/int/branch/afc.hpp +++ b/gecode/int/branch/afc.hpp @@ -35,15 +35,6 @@ namespace Gecode { forceinline IntAFC::IntAFC(void) {} - forceinline - IntAFC::IntAFC(const IntAFC& a) - : AFC(a) {} - - forceinline IntAFC& - IntAFC::operator=(const IntAFC& a) { - return static_cast(AFC::operator=(a)); - } - forceinline IntAFC::IntAFC(Home home, const IntVarArgs& x, double d, bool share) { AFC::init(home, x, d, share); @@ -57,15 +48,6 @@ namespace Gecode { forceinline BoolAFC::BoolAFC(void) {} - forceinline - BoolAFC::BoolAFC(const BoolAFC& a) - : AFC(a) {} - - forceinline BoolAFC& - BoolAFC::operator=(const BoolAFC& a) { - return static_cast(AFC::operator=(a)); - } - forceinline BoolAFC::BoolAFC(Home home, const BoolVarArgs& x, double d, bool share) { AFC::init(home, x, d, share); diff --git a/gecode/int/var/bool.hpp b/gecode/int/var/bool.hpp index e5f4a9f131..be548ae677 100644 --- a/gecode/int/var/bool.hpp +++ b/gecode/int/var/bool.hpp @@ -46,9 +46,6 @@ namespace Gecode { forceinline BoolVar::BoolVar(void) {} forceinline - BoolVar::BoolVar(const BoolVar& y) - : VarImpVar(y.varimp()) {} - forceinline BoolVar::BoolVar(const Int::BoolView& y) : VarImpVar(y.varimp()) {} diff --git a/gecode/int/var/int.hpp b/gecode/int/var/int.hpp index e39a6b0919..1130dd6f89 100644 --- a/gecode/int/var/int.hpp +++ b/gecode/int/var/int.hpp @@ -45,9 +45,6 @@ namespace Gecode { forceinline IntVar::IntVar(void) {} forceinline - IntVar::IntVar(const IntVar& y) - : VarImpVar(y.varimp()) {} - forceinline IntVar::IntVar(const Int::IntView& y) : VarImpVar(y.varimp()) {} diff --git a/gecode/kernel/branch/afc.hpp b/gecode/kernel/branch/afc.hpp index 32e6479585..540350197e 100644 --- a/gecode/kernel/branch/afc.hpp +++ b/gecode/kernel/branch/afc.hpp @@ -52,10 +52,6 @@ namespace Gecode { * */ AFC(void); - /// Copy constructor - AFC(const AFC& a); - /// Assignment operator - AFC& operator=(const AFC& a); /** \brief Initialize for variables \a x and decay factor \a d * * If several AFC objects are created for a space or its clones, @@ -78,9 +74,6 @@ namespace Gecode { GECODE_KERNEL_EXPORT static const AFC def; //@} - /// Destructor - ~AFC(void); - /// \name Information access //@{ /// Return number of AFC values @@ -143,16 +136,6 @@ namespace Gecode { static_cast(home).afc_unshare(); } - forceinline - AFC::AFC(const AFC& a) - : n(a.n) {} - forceinline AFC& - AFC::operator=(const AFC& a) { - n = a.n; - return *this; - } - forceinline AFC::~AFC(void) {} - forceinline void AFC::decay(Space& home, double d) { if ((d < 0.0) || (d > 1.0)) diff --git a/gecode/kernel/branch/view.hpp b/gecode/kernel/branch/view.hpp index 35699dafd1..f0cd33eed3 100644 --- a/gecode/kernel/branch/view.hpp +++ b/gecode/kernel/branch/view.hpp @@ -46,8 +46,6 @@ namespace Gecode { const int pos; /// Create position information Pos(int p); - /// Create position information - Pos(const Pos& p); }; /// %Choices storing position @@ -117,9 +115,6 @@ namespace Gecode { forceinline Pos::Pos(int p) : pos(p) {} - forceinline - Pos::Pos(const Pos& p) - : pos(p.pos) {} /* * Choice with position diff --git a/gecode/kernel/core.hpp b/gecode/kernel/core.hpp index 08d0565159..79a77a4f39 100644 --- a/gecode/kernel/core.hpp +++ b/gecode/kernel/core.hpp @@ -748,10 +748,6 @@ namespace Gecode { /// Constructor GECODE_KERNEL_EXPORT Group(void); - /// Copy constructor - Group(const Group& g); - /// Assignment operator - Group& operator=(const Group& g); /// Return a unique id for the group unsigned int id(void) const; /// Check whether actor group \a a is included in this group @@ -786,10 +782,6 @@ namespace Gecode { //@{ /// Constructor PropagatorGroup(void); - /// Copy constructor - PropagatorGroup(const PropagatorGroup& g); - /// Assignment operator - PropagatorGroup& operator=(const PropagatorGroup& g); /// To augment a space argument Home operator()(Space& home); //@} @@ -857,10 +849,6 @@ namespace Gecode { //@{ /// Constructor BrancherGroup(void); - /// Copy constructor - BrancherGroup(const BrancherGroup& g); - /// Assignment operator - BrancherGroup& operator=(const BrancherGroup& g); /// To augment a space argument Home operator()(Space& home); //@} @@ -924,9 +912,9 @@ namespace Gecode { Home(Space& s, Propagator* p = nullptr, PropagatorGroup pg = PropagatorGroup::def, BrancherGroup bg = BrancherGroup::def); /// Copy constructor - Home(const Home& h); - /// Assignment operator - Home& operator=(const Home& h); + Home(const Home& h) = default; + /// Homes are not assignable: a home never changes its space + Home& operator=(const Home& h) = delete; /// Retrieve the space of the home operator Space&(void); //@} @@ -1668,15 +1656,11 @@ namespace Gecode { /// Create local handle that points to local object \a lo LocalHandle(LocalObject* lo); /// Copy constructor - LocalHandle(const LocalHandle& lh); + LocalHandle(const LocalHandle& lh) = default; public: - /// Assignment operator - LocalHandle& operator=(const LocalHandle& lh); /// Updating during cloning void update(Space& home, LocalHandle& lh); - /// Destructor - ~LocalHandle(void); protected: /// Access to the local object @@ -2389,8 +2373,8 @@ namespace Gecode { */ GECODE_KERNEL_EXPORT Space(Space& s); - /// Assignment operator - Space& operator=(const Space& s) = default; + /// Spaces are not assignable: use cloning to copy a space + Space& operator=(const Space& s) = delete; /** * \brief Destructor * \ingroup TaskModelScript @@ -3800,17 +3784,6 @@ namespace Gecode { forceinline Home::Home(Space& s0, Propagator* p0, PropagatorGroup pg0, BrancherGroup bg0) : s(s0), p(p0), pg(pg0), bg(bg0) {} - forceinline - Home::Home(const Home& h) - : s(h.s), p(h.p), pg(h.pg), bg(h.bg) {} - forceinline Home& - Home::operator=(const Home& h) { - s = h.s; - p = h.p; - pg = h.pg; - bg = h.bg; - return *this; - } forceinline Home:: operator Space&(void) { return s; @@ -4317,15 +4290,6 @@ namespace Gecode { forceinline LocalHandle::LocalHandle(LocalObject* lo) : o(lo) {} - forceinline - LocalHandle::LocalHandle(const LocalHandle& lh) - : o(lh.o) {} - forceinline LocalHandle& - LocalHandle::operator=(const LocalHandle& lh) { - o = lh.o; - return *this; - } - forceinline LocalHandle::~LocalHandle(void) {} forceinline LocalObject* LocalHandle::object(void) const { return o; @@ -5591,16 +5555,6 @@ namespace Gecode { return (gid != GROUPID_ALL) && (gid != GROUPID_DEF); } - forceinline - Group::Group(const Group& g) - : gid(g.gid) {} - - forceinline Group& - Group::operator=(const Group& g) { - gid = g.gid; - return *this; - } - forceinline unsigned int Group::id(void) const { return gid; @@ -5613,15 +5567,6 @@ namespace Gecode { PropagatorGroup::PropagatorGroup(unsigned int gid) : Group(gid) {} - forceinline - PropagatorGroup::PropagatorGroup(const PropagatorGroup& g) - : Group(g) {} - - forceinline PropagatorGroup& - PropagatorGroup::operator=(const PropagatorGroup& g) { - return static_cast(Group::operator=(g)); - } - forceinline Home PropagatorGroup::operator()(Space& home) { return Home(home, nullptr, *this, BrancherGroup::def); @@ -5650,15 +5595,6 @@ namespace Gecode { BrancherGroup::BrancherGroup(unsigned int gid) : Group(gid) {} - forceinline - BrancherGroup::BrancherGroup(const BrancherGroup& g) - : Group(g) {} - - forceinline BrancherGroup& - BrancherGroup::operator=(const BrancherGroup& g) { - return static_cast(Group::operator=(g)); - } - forceinline Home BrancherGroup::operator()(Space& home) { return Home(home, nullptr, PropagatorGroup::def, *this); diff --git a/gecode/kernel/data/array.hpp b/gecode/kernel/data/array.hpp index 0725cd8e9d..bafdde2961 100644 --- a/gecode/kernel/data/array.hpp +++ b/gecode/kernel/data/array.hpp @@ -150,9 +150,9 @@ namespace Gecode { /// Initialize from variable argument array \a a (copy elements) VarArray(Space& home, const VarArgArray&); /// Initialize from variable array \a a (share elements) - VarArray(const VarArray& a); - /// Initialize from variable array \a a (share elements) - const VarArray& operator=(const VarArray& a); + VarArray(const VarArray& a) = default; + /// Assign variable array \a a (share elements) + VarArray& operator=(const VarArray& a) = default; //@} /// \name Array size @@ -287,13 +287,13 @@ namespace Gecode { /// Allocate array with \a m views ViewArray(Region& r, int m); /// Initialize from view array \a a (share elements) - ViewArray(const ViewArray& a); + ViewArray(const ViewArray& a) = default; /// Initialize from view array \a a (copy elements) ViewArray(Space& home, const ViewArray& a); /// Initialize from view array \a a (copy elements) ViewArray(Region& r, const ViewArray& a); - /// Initialize from view array \a a (share elements) - const ViewArray& operator=(const ViewArray& a); + /// Assign view array \a a (share elements) + ViewArray& operator=(const ViewArray& a) = default; /** * \brief Initialize from variable argument array \a a (copy elements) * @@ -897,21 +897,6 @@ namespace Gecode { x = (n > 0) ? home.alloc(n) : nullptr; } - template - forceinline - VarArray::VarArray(const VarArray& a) { - n = a.n; - x = a.x; - } - - template - inline const VarArray& - VarArray::operator=(const VarArray& a) { - n = a.n; - x = a.x; - return *this; - } - template forceinline int VarArray::size(void) const { @@ -1118,19 +1103,6 @@ namespace Gecode { } } - template - forceinline - ViewArray::ViewArray(const ViewArray& a) - : n(a.n), x(a.x) {} - - template - forceinline const ViewArray& - ViewArray::operator=(const ViewArray& a) { - n = a.n; - x = a.x; - return *this; - } - template forceinline int ViewArray::size(void) const { diff --git a/gecode/set.hh b/gecode/set.hh index a7dbc555f6..6878c9df68 100644 --- a/gecode/set.hh +++ b/gecode/set.hh @@ -126,7 +126,7 @@ namespace Gecode { /// Default constructor SetVar(void); /// Initialize from set variable \a y - SetVar(const SetVar& y); + SetVar(const SetVar& y) = default; /// Initialize from set view \a y SetVar(const Set::SetView& y); @@ -564,7 +564,7 @@ namespace Gecode { /// Default constructor (array of size 0) SetVarArray(void); /// Initialize from set variable array \a a (share elements) - SetVarArray(const SetVarArray&); + SetVarArray(const SetVarArray&) = default; /// Initialize from set variable argument array \a a (copy elements) SetVarArray(Space& home, const SetVarArgs&); /// Allocate array for \a n set variables (variables are uninitialized) @@ -1045,10 +1045,6 @@ namespace Gecode { * */ SetAFC(void); - /// Copy constructor - SetAFC(const SetAFC& a); - /// Assignment operator - SetAFC& operator=(const SetAFC& a); /** * \brief Initialize for set variables \a x and decay factor \a d * diff --git a/gecode/set/array.hpp b/gecode/set/array.hpp index 7432d43d21..d6297bc477 100644 --- a/gecode/set/array.hpp +++ b/gecode/set/array.hpp @@ -74,10 +74,6 @@ namespace Gecode { forceinline SetVarArray::SetVarArray(void) {} - forceinline - SetVarArray::SetVarArray(const SetVarArray& a) - : VarArray(a) {} - forceinline SetVarArray::SetVarArray(Space& home, const SetVarArgs& a) : VarArray(home, a) {} diff --git a/gecode/set/branch/afc.hpp b/gecode/set/branch/afc.hpp index 2bc14e5b97..35a85e929a 100644 --- a/gecode/set/branch/afc.hpp +++ b/gecode/set/branch/afc.hpp @@ -35,15 +35,6 @@ namespace Gecode { forceinline SetAFC::SetAFC(void) {} - forceinline - SetAFC::SetAFC(const SetAFC& a) - : AFC(a) {} - - forceinline SetAFC& - SetAFC::operator=(const SetAFC& a) { - return static_cast(AFC::operator=(a)); - } - forceinline SetAFC::SetAFC(Home home, const SetVarArgs& x, double d, bool share) { AFC::init(home, x, d, share); diff --git a/gecode/set/var/set.hpp b/gecode/set/var/set.hpp index c9d5469696..df750b235d 100644 --- a/gecode/set/var/set.hpp +++ b/gecode/set/var/set.hpp @@ -44,10 +44,6 @@ namespace Gecode { forceinline SetVar::SetVar(void) {} - forceinline - SetVar::SetVar(const SetVar& y) - : VarImpVar(y.varimp()) {} - forceinline SetVar::SetVar(const Set::SetView& y) : VarImpVar(y.varimp()) {} diff --git a/test/array.cpp b/test/array.cpp index 40c59bfaf7..1c1df8f79b 100644 --- a/test/array.cpp +++ b/test/array.cpp @@ -32,7 +32,14 @@ #include #include +#ifdef GECODE_HAS_SET_VARS +#include +#endif +#ifdef GECODE_HAS_FLOAT_VARS +#include +#endif +#include #include #include "test/test.hh" @@ -60,6 +67,49 @@ namespace Test { + /* + * Shallow handles copy a few pointers or ids and must stay trivially + * copyable, so that a hand-written copy member cannot come back. + */ + static_assert(std::is_trivially_copyable_v); + static_assert(std::is_trivially_copyable_v); + static_assert(std::is_trivially_copyable_v); + static_assert(std::is_trivially_copyable_v); + static_assert(std::is_trivially_copyable_v); + static_assert(std::is_trivially_copyable_v); + static_assert(std::is_trivially_copyable_v); + static_assert(std::is_trivially_copyable_v); + static_assert(std::is_trivially_copyable_v); + static_assert(std::is_trivially_copyable_v); + static_assert(std::is_trivially_copyable_v); + static_assert(std::is_trivially_copyable_v); + static_assert(std::is_trivially_copyable_v); + static_assert(std::is_trivially_copyable_v); + static_assert(std::is_trivially_copyable_v); + static_assert(std::is_trivially_copyable_v); + static_assert(std::is_trivially_copyable_v>); + static_assert(std::is_trivially_copyable_v>); + static_assert(std::is_trivially_copyable_v>); +#ifdef GECODE_HAS_SET_VARS + static_assert(std::is_trivially_copyable_v); + static_assert(std::is_trivially_copyable_v); + static_assert(std::is_trivially_copyable_v); + static_assert(std::is_trivially_copyable_v>); +#endif +#ifdef GECODE_HAS_FLOAT_VARS + static_assert(std::is_trivially_copyable_v); + static_assert(std::is_trivially_copyable_v); + static_assert(std::is_trivially_copyable_v); + static_assert(std::is_trivially_copyable_v>); +#endif + + /* + * A home never changes its space, and a space is copied only by + * cloning, so neither is assignable. + */ + static_assert(!std::is_copy_assignable_v); + static_assert(!std::is_copy_assignable_v); + /// Tests for arrays namespace Array { From eca77c12a77e76aa13cfbc89612e2d718d7c6f53 Mon Sep 17 00:00:00 2001 From: Mikael Zayenz Lagerkvist Date: Wed, 4 Nov 2026 04:08:22 +0100 Subject: [PATCH 2/4] Default and delete special members by tool run Special members that only copy, move, or destroy members are now defaulted, and private undefined members are public = delete. modernize-use-equals-default and modernize-use-equals-delete are enabled in .clang-tidy, and docs/code-style.md states the rule. Cloning constructors, a configuration-dependent constructor, and default constructors of types that are value-initialized stay hand-written with NOLINTNEXTLINE (keep.tsv lists each with its reason). Out-of-line = default definitions move into their classes so the classes stay trivial. The changelog names the source breaks, including that const default-initialization stops compiling for the listed types. Reproduce on the parent commit, from the source root, with a build/full configured and built like the inventory's (LLVM 22, uv, Homebrew Bison 3.8 and Flex 2.6 on PATH): sh .zdev/modern-classes/background/equals-default/reproduce.sh build/full 10 which runs, with D=.zdev/modern-classes/background/equals-default and B=build/full: git apply $D/genvarimp.patch cmake --build $B --target regenerate python3 $D/nolint.py $D/keep.tsv python3 $D/run.py $B $B/equals-default 10 equals mv $B/equals-default/fixes-*.yaml $B/equals-default/fixes/ clang-apply-replacements $B/equals-default/fixes python3 $D/relocate.py $B 10 uv run misc/check.py format git apply $D/manual.patch uv run misc/check.py format Zdev-Change-Id: Z0f66c3beabdceb05bd6e94ff7f8e64632fe7174275a162647df20afc1f67a826 --- .clang-tidy | 2 + changelog.in | 29 +++++++++++ docs/code-style.md | 23 +++++++++ examples/job-shop.cpp | 2 + examples/knights.cpp | 2 + examples/open-shop.cpp | 1 + examples/sudoku-advanced.cpp | 1 + gecode/driver/script.hpp | 5 +- gecode/flatzinc.hh | 12 ++--- gecode/flatzinc/ast.hh | 3 +- gecode/flatzinc/blackbox-backend.hh | 2 +- gecode/flatzinc/blackbox-process.hh | 3 +- gecode/flatzinc/blackbox-propagator.cpp | 2 +- gecode/flatzinc/blackbox.hh | 2 +- gecode/flatzinc/flatzinc.cpp | 10 ++-- gecode/flatzinc/parser.hh | 1 + gecode/flatzinc/varspec.hh | 2 +- gecode/float.hh | 24 ++++----- gecode/float/array.hpp | 10 ---- gecode/float/branch/action.hpp | 7 --- gecode/float/branch/afc.hpp | 3 -- gecode/float/branch/chb.hpp | 7 --- gecode/float/trace/trace-view.hpp | 4 +- gecode/float/val.hpp | 10 ---- gecode/float/var/float.hpp | 2 - gecode/float/view.hpp | 8 +-- gecode/float/view/float.hpp | 2 - gecode/float/view/minus.hpp | 2 - gecode/float/view/offset.hpp | 2 - gecode/float/view/scale.hpp | 2 - gecode/gist.hh | 2 +- gecode/gist/gist.cpp | 4 +- gecode/gist/gist.hpp | 3 -- gecode/gist/visualnode.hh | 12 ++--- gecode/instance/impl.hpp | 2 +- gecode/int.hh | 60 +++++++++++------------ gecode/int/array.hpp | 20 -------- gecode/int/bin-packing.hh | 6 +-- gecode/int/bin-packing/conflict-graph.hpp | 5 +- gecode/int/bin-packing/propagate.hpp | 3 +- gecode/int/branch/action.hpp | 14 ------ gecode/int/branch/afc.hpp | 6 --- gecode/int/branch/chb.hpp | 14 ------ gecode/int/cumulative/task.hpp | 6 +++ gecode/int/cumulatives/val.hpp | 1 + gecode/int/distinct.hh | 4 +- gecode/int/distinct/dom-ctrl.hpp | 4 -- gecode/int/distinct/graph.hpp | 4 -- gecode/int/element/view.hpp | 5 +- gecode/int/extensional.hh | 4 +- gecode/int/extensional/compact.hpp | 5 -- gecode/int/extensional/dfa.hpp | 8 +-- gecode/int/extensional/layered-graph.hpp | 3 -- gecode/int/extensional/tuple-set.cpp | 1 - gecode/int/extensional/tuple-set.hpp | 3 -- gecode/int/gcc/dom-sup.hpp | 14 ++---- gecode/int/gcc/view.hpp | 2 + gecode/int/growable-int-set.hh | 4 +- gecode/int/int-set-1.hpp | 6 --- gecode/int/ldsb.hh | 4 +- gecode/int/ldsb/sym-imp.hpp | 2 +- gecode/int/ldsb/sym-obj.cpp | 2 +- gecode/int/linear.hh | 4 +- gecode/int/linear/bool-scale.hpp | 4 -- gecode/int/linear/int-dom.hpp | 4 +- gecode/int/linear/int-noview.hpp | 11 ++--- gecode/int/min-distance.cpp | 2 +- gecode/int/no-overlap.hh | 2 +- gecode/int/no-overlap/dim.hpp | 2 - gecode/int/open-var-list.cpp | 4 -- gecode/int/open-var-list.hpp | 6 --- gecode/int/task.hh | 16 +++--- gecode/int/task/iter.hpp | 4 -- gecode/int/task/man-to-opt.hpp | 4 -- gecode/int/trace/bool-trace-view.hpp | 4 +- gecode/int/trace/int-trace-view.hpp | 1 + gecode/int/unary.hh | 4 +- gecode/int/unary/task.hpp | 8 +-- gecode/int/var-imp.hpp | 4 +- gecode/int/var-imp/int.hpp | 5 +- gecode/int/var/bool.hpp | 2 - gecode/int/var/int.hpp | 6 +-- gecode/int/view.hpp | 14 +++--- gecode/int/view/bool.hpp | 7 +-- gecode/int/view/cached.hpp | 10 +--- gecode/int/view/constint.hpp | 6 +-- gecode/int/view/int.hpp | 3 +- gecode/int/view/iter.hpp | 4 -- gecode/int/view/minus.hpp | 3 +- gecode/int/view/neg-bool.hpp | 7 +-- gecode/int/view/offset.hpp | 6 +-- gecode/int/view/scale.hpp | 9 ++-- gecode/int/view/zero.hpp | 7 +-- gecode/iter/ranges-add.hpp | 12 +---- gecode/iter/ranges-append.hpp | 12 +---- gecode/iter/ranges-array.hpp | 5 +- gecode/iter/ranges-cache.hpp | 11 +---- gecode/iter/ranges-compl.hpp | 12 +---- gecode/iter/ranges-diff.hpp | 6 +-- gecode/iter/ranges-empty.hpp | 5 +- gecode/iter/ranges-inter.hpp | 11 +---- gecode/iter/ranges-map.hpp | 12 +---- gecode/iter/ranges-minmax.hpp | 5 +- gecode/iter/ranges-minus.hpp | 11 +---- gecode/iter/ranges-negative.hpp | 6 +-- gecode/iter/ranges-offset.hpp | 6 +-- gecode/iter/ranges-positive.hpp | 6 +-- gecode/iter/ranges-rangelist.hpp | 5 +- gecode/iter/ranges-scale.hpp | 12 +---- gecode/iter/ranges-singleton-append.hpp | 6 +-- gecode/iter/ranges-singleton.hpp | 5 +- gecode/iter/ranges-union.hpp | 6 +-- gecode/iter/ranges-values.hpp | 6 +-- gecode/iter/values-array.hpp | 5 +- gecode/iter/values-inter.hpp | 6 +-- gecode/iter/values-map.hpp | 6 +-- gecode/iter/values-minus.hpp | 11 +---- gecode/iter/values-negative.hpp | 6 +-- gecode/iter/values-offset.hpp | 6 +-- gecode/iter/values-positive.hpp | 6 +-- gecode/iter/values-ranges.hpp | 6 +-- gecode/iter/values-singleton.hpp | 5 +- gecode/iter/values-unique.hpp | 6 +-- gecode/kernel/branch/action.cpp | 4 -- gecode/kernel/branch/action.hpp | 9 ++-- gecode/kernel/branch/chb.cpp | 4 -- gecode/kernel/branch/chb.hpp | 9 ++-- gecode/kernel/branch/filter.hpp | 1 + gecode/kernel/branch/print.hpp | 1 + gecode/kernel/branch/val-sel-commit.hpp | 2 +- gecode/kernel/branch/view-sel.hpp | 2 +- gecode/kernel/core.cpp | 6 +-- gecode/kernel/core.hpp | 32 +++++------- gecode/kernel/data/array.hpp | 12 +---- gecode/kernel/data/shared-array.hpp | 6 +-- gecode/kernel/data/shared-data.hpp | 13 ++--- gecode/kernel/memory/allocators.hpp | 4 +- gecode/kernel/memory/manager.hpp | 5 +- gecode/kernel/range-list.hpp | 1 + gecode/kernel/shared-space-data.hpp | 17 ++----- gecode/kernel/trace/filter.cpp | 3 +- gecode/kernel/trace/filter.hpp | 2 +- gecode/kernel/trace/tracer.hpp | 15 ++---- gecode/kernel/var-imp.hpp | 20 ++------ gecode/kernel/view.hpp | 6 +-- gecode/minimodel.hh | 16 +++--- gecode/minimodel/bool-expr.cpp | 2 +- gecode/minimodel/bool-expr.hpp | 3 -- gecode/minimodel/float-expr.hpp | 2 +- gecode/minimodel/float-rel.hpp | 2 - gecode/minimodel/int-expr.hpp | 2 +- gecode/minimodel/int-rel.hpp | 2 - gecode/minimodel/optimize.hpp | 16 ++---- gecode/minimodel/reg.cpp | 4 +- gecode/minimodel/set-rel.hpp | 3 -- gecode/search.hh | 12 ++--- gecode/search/cpprofiler/tracer.cpp | 4 +- gecode/search/cutoff.hpp | 4 +- gecode/search/engine.cpp | 2 +- gecode/search/nogoods.hh | 2 +- gecode/search/nogoods.hpp | 3 -- gecode/search/par/path.hpp | 1 + gecode/search/seq/lds.hpp | 1 + gecode/search/seq/path.hpp | 1 + gecode/search/stop.hpp | 4 +- gecode/search/trace-recorder.hpp | 8 +-- gecode/search/tracer.cpp | 2 +- gecode/search/tracer.hpp | 3 +- gecode/set.hh | 24 ++++----- gecode/set/array.hpp | 10 ---- gecode/set/branch/action.hpp | 7 --- gecode/set/branch/afc.hpp | 3 -- gecode/set/branch/chb.hpp | 7 --- gecode/set/int/weights.hpp | 6 +-- gecode/set/rel/lq.hpp | 4 +- gecode/set/trace/trace-view.hpp | 1 + gecode/set/var-imp.hpp | 22 ++++----- gecode/set/var-imp/integerset.hpp | 11 ----- gecode/set/var-imp/iter.hpp | 4 -- gecode/set/var-imp/set.hpp | 10 +--- gecode/set/var/set.hpp | 12 ----- gecode/set/view.hpp | 12 ++--- gecode/set/view/cached.hpp | 8 +-- gecode/set/view/complement.hpp | 12 ++--- gecode/set/view/const.hpp | 12 ++--- gecode/set/view/set.hpp | 4 +- gecode/set/view/singleton.hpp | 5 +- gecode/support/allocator.hpp | 4 +- gecode/support/bitset-base.hpp | 16 +++--- gecode/support/heap.cpp | 7 --- gecode/support/heap.hpp | 6 +-- gecode/support/run-jobs.hpp | 4 +- gecode/support/thread.hpp | 28 ++++------- misc/genvarimp.py | 8 +-- test/array.cpp | 1 + test/branch.cpp | 3 +- test/fault.cpp | 9 ++-- test/float.hpp | 2 +- test/float/arithmetic.cpp | 1 + test/int.hpp | 2 +- test/int/bin-packing.cpp | 5 +- test/int/cumulative.cpp | 1 + test/int/distinct.cpp | 3 +- test/int/gcc.cpp | 1 + test/int/no-overlap.cpp | 1 + test/int/open-var-list.cpp | 2 +- test/region.cpp | 3 +- test/search.cpp | 22 +++++++-- test/set.hh | 6 +-- 209 files changed, 456 insertions(+), 940 deletions(-) diff --git a/.clang-tidy b/.clang-tidy index 469685e6f4..011f00661b 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -17,6 +17,8 @@ Checks: >- bugprone-use-after-move, bugprone-virtual-near-miss, modernize-deprecated-headers, + modernize-use-equals-default, + modernize-use-equals-delete, modernize-use-nullptr, modernize-use-override, performance-avoid-endl, diff --git a/changelog.in b/changelog.in index ab16c3f7c9..bb2476baa5 100644 --- a/changelog.in +++ b/changelog.in @@ -100,6 +100,35 @@ Delete the copy assignment of Home and of Space. Assigning one Home to another copy-assigned the whole Space that the home refers to. A Home never changes its space; construct a new Home instead. To copy a Space, clone it. +[ENTRY] +Module: kernel +What: change +Rank: minor +[DESCRIPTION] +Default special members that only construct, copy, or destroy members, and +delete with = delete the members that must not be called. Across the +library, default constructors, copy constructors, copy assignments, and +destructors with empty or member-wise bodies are now defaulted on their first +declaration; among them are those of the variables, most views, FloatVal, +IntSet, TupleSet, DFA, Action, CHB, the argument arrays, and the range and +value iterators. Behaviour is unchanged, but the ABI changes: several +members that the libraries exported, such as the copy constructors of +TupleSet, Action, and CHB, are now inline. +[MORE] +Copy members that were private and undefined, such as those of Search::Base, +Support::BitSetBase, Set::GLBndSet, and FlatZinc::Printer, are now public +and deleted, so copying one is reported as a call to a deleted function. + +A defaulted default constructor is no longer user-provided. A class with +such a constructor and a field without an initializer can no longer be +default-initialized as a const object: `const Gecode::IntSetRanges r;` no +longer compiles. Initialize the object, or drop the const. This affects +most range and value iterators: IntSetRanges, IntSetValues, IntVarValues, +SetVarGlbRanges, SetVarLubRanges, SetVarUnknownRanges, the iterators in +Iter::Ranges and Iter::Values, and the range and value iterators of views +such as Int::ViewRanges and Set::UnknownRanges. It also affects SetRel, +FreeList, Float::OffsetView, and Search::TraceRecorder::ID. + [ENTRY] Module: support What: removed diff --git a/docs/code-style.md b/docs/code-style.md index 6f3a5308f7..c69d8cef48 100644 --- a/docs/code-style.md +++ b/docs/code-style.md @@ -139,6 +139,29 @@ strings, and callbacks. Their copies touch a reference count or allocate, so they follow the rule above. `FloatVal` is not exempt either: it is two doubles, not a handle. +Special members follow the rule of zero: a class whose members copy, move, +and destroy themselves declares no copy member, move member, or destructor. +Where a special member must be declared, for example a default constructor +beside other constructors or a virtual destructor, write `= default` instead +of an empty body or a member-wise copy, on the member's first declaration in +the class. A member defaulted out of line is user-provided and keeps the +class non-trivial. Virtual destructors may stay out of line: their class is +never trivial, and one defined in a .cpp file decides where the vtable is +emitted. A member that must not be called is a public `= delete`, not a +private member without a definition. `modernize-use-equals-default` and +`modernize-use-equals-delete` enforce these rules. + +Some hand-written members stay, each after a +`// NOLINTNEXTLINE(modernize-use-equals-default)` line. Cloning constructors +such as `Space(Space&)` are not copy members: they take their source by +non-const reference because cloning writes forwarding pointers into it, and +they update their variables with `update()`. An empty default constructor +stays where defaulting it would change what value-initialization does: +`T()`, `T{}`, and the `alloc(n)` functions of spaces, regions, and the +heap zero a class whose default constructor is not user-provided, while the +empty constructor leaves fields without an initializer untouched. A +constructor whose body is empty only in some configurations stays as well. + Other performance checks need focused review: `performance-enum-size` changes layouts and ABI, and `performance-no-int-to-ptr` conflicts with deliberate pointer tagging. Review `noexcept` guarantees, destructor triviality, and math diff --git a/examples/job-shop.cpp b/examples/job-shop.cpp index 4f9649ed53..838d68fb97 100644 --- a/examples/job-shop.cpp +++ b/examples/job-shop.cpp @@ -483,6 +483,7 @@ class JobShopProbe : public JobShopBase { assign(*this, makespan, INT_ASSIGN_MIN()); } /// Constructor for cloning \a s + // NOLINTNEXTLINE(modernize-use-equals-default) JobShopProbe(JobShopProbe& s) : JobShopBase(s) {} /// Copy during cloning Space* @@ -641,6 +642,7 @@ class JobShopSolve : public JobShopBase { assign(*this, makespan, INT_ASSIGN_MIN()); } /// Constructor for cloning \a s + // NOLINTNEXTLINE(modernize-use-equals-default) JobShopSolve(JobShopSolve& s) : JobShopBase(s), sorder(s.sorder), fst(s.fst), snd(s.snd), iafc(s.iafc), iaction(s.iaction), baction(s.baction), ichb(s.ichb), bchb(s.bchb), rnd(s.rnd) {} diff --git a/examples/knights.cpp b/examples/knights.cpp index b6ceb06be5..dd4487d57f 100644 --- a/examples/knights.cpp +++ b/examples/knights.cpp @@ -283,6 +283,7 @@ class KnightsReified : public Knights { } } /// Constructor for cloning \a s + // NOLINTNEXTLINE(modernize-use-equals-default) KnightsReified(KnightsReified& s) : Knights(s) {} /// Copy during cloning Space* @@ -313,6 +314,7 @@ class KnightsCircuit : public Knights { dom(*this, succ[f], neighbors(f)); } /// Constructor for cloning \a s + // NOLINTNEXTLINE(modernize-use-equals-default) KnightsCircuit(KnightsCircuit& s) : Knights(s) {} /// Copy during cloning Space* diff --git a/examples/open-shop.cpp b/examples/open-shop.cpp index 92ed0f8aac..e14fe1741a 100644 --- a/examples/open-shop.cpp +++ b/examples/open-shop.cpp @@ -78,6 +78,7 @@ class OpenShop : public IntMinimizeScript { int m; //< Machine int p; //< Processing time /// Default constructor + // NOLINTNEXTLINE(modernize-use-equals-default) Task(void) {} /// Constructor Task(int j0, int m0, int p0) : j(j0), m(m0), p(p0) {} diff --git a/examples/sudoku-advanced.cpp b/examples/sudoku-advanced.cpp index 178e94c0cd..ed1c525ea8 100644 --- a/examples/sudoku-advanced.cpp +++ b/examples/sudoku-advanced.cpp @@ -100,6 +100,7 @@ class Sudoku : public Script { } /// Constructor for cloning \a s + // NOLINTNEXTLINE(modernize-use-equals-default) Sudoku(Sudoku& s) : Script(s), nn(s.nn), bw(s.bw), bh(s.bh), givens(s.givens) {} }; diff --git a/gecode/driver/script.hpp b/gecode/driver/script.hpp index bc19b13343..34864be482 100644 --- a/gecode/driver/script.hpp +++ b/gecode/driver/script.hpp @@ -225,7 +225,7 @@ namespace Gecode { namespace Driver { class ScriptGetInfo : public CPProfilerSearchTracer::GetInfo { public: /// Initialize - ScriptGetInfo(void); + ScriptGetInfo(void) = default; /// Return info for a space (which must be a script) std::string get_info(const Space& home) const override; }; @@ -267,9 +267,6 @@ namespace Gecode { namespace Driver { #ifdef GECODE_HAS_CPPROFILER - template - ScriptGetInfo::ScriptGetInfo(void) {} - template std::string ScriptGetInfo::get_info(const Space& home) const { diff --git a/gecode/flatzinc.hh b/gecode/flatzinc.hh index 28a5bd9cd7..4c2021bd59 100644 --- a/gecode/flatzinc.hh +++ b/gecode/flatzinc.hh @@ -202,9 +202,9 @@ namespace Gecode { namespace FlatZinc { #endif ); - private: - Printer(const Printer&); - Printer& operator=(const Printer&); + public: + Printer(const Printer&) = delete; + Printer& operator=(const Printer&) = delete; }; /** @@ -463,7 +463,7 @@ namespace Gecode { namespace FlatZinc { /// Constructor BranchInformation(void); /// Copy constructor - BranchInformation(const BranchInformation& bi); + BranchInformation(const BranchInformation& bi) = default; /// Initialise for use void init(void); /// Add new brancher information @@ -587,12 +587,12 @@ namespace Gecode { namespace FlatZinc { public: OnRestartHandle() : SharedHandle() {} - OnRestartHandle(const OnRestartHandle& handle) : SharedHandle(handle) {} + OnRestartHandle(const OnRestartHandle& handle) = default; OnRestartHandle& operator=(const OnRestartHandle& handle) { return static_cast(SharedHandle::operator=(handle)); } - virtual ~OnRestartHandle() {}; + virtual ~OnRestartHandle() = default; void init() { diff --git a/gecode/flatzinc/ast.hh b/gecode/flatzinc/ast.hh index 8ba821e982..7cd63ee311 100644 --- a/gecode/flatzinc/ast.hh +++ b/gecode/flatzinc/ast.hh @@ -181,6 +181,7 @@ namespace Gecode { namespace FlatZinc { namespace AST { int min; int max; std::vector s; + // NOLINTNEXTLINE(modernize-use-equals-default) SetLit(void) {} SetLit(int min0, int max0) : interval(true), min(min0), max(max0) {} SetLit(const std::vector& s0) : interval(false), s(s0) {} @@ -331,7 +332,7 @@ namespace Gecode { namespace FlatZinc { namespace AST { } }; - inline Node::~Node(void) {} + inline Node::~Node(void) = default; inline void Node::append(Node* new_node) { diff --git a/gecode/flatzinc/blackbox-backend.hh b/gecode/flatzinc/blackbox-backend.hh index e558ce33b5..c2391995c3 100644 --- a/gecode/flatzinc/blackbox-backend.hh +++ b/gecode/flatzinc/blackbox-backend.hh @@ -68,7 +68,7 @@ namespace Gecode { namespace FlatZinc { /// Backend for a deterministic FlatZinc blackbox function. class BlackBoxBackend : public SharedHandle::Object { public: - ~BlackBoxBackend(void) override {} + ~BlackBoxBackend(void) override = default; virtual void run(BlackBoxCall& call) = 0; void run(const std::vector& int_input, const std::vector& float_input, diff --git a/gecode/flatzinc/blackbox-process.hh b/gecode/flatzinc/blackbox-process.hh index d5272f6f3c..eed6c3329f 100644 --- a/gecode/flatzinc/blackbox-process.hh +++ b/gecode/flatzinc/blackbox-process.hh @@ -26,6 +26,7 @@ namespace Gecode { namespace FlatZinc { #ifdef GECODE_HAS_THREADS std::thread::id owner; #endif + // NOLINTNEXTLINE(modernize-use-equals-default) BlackBoxProcessSession(void) #ifdef GECODE_HAS_THREADS : owner(std::this_thread::get_id()) @@ -34,7 +35,7 @@ namespace Gecode { namespace FlatZinc { } public: - virtual ~BlackBoxProcessSession(void) {} + virtual ~BlackBoxProcessSession(void) = default; bool owned_by_current_thread(void) const { #ifdef GECODE_HAS_THREADS diff --git a/gecode/flatzinc/blackbox-propagator.cpp b/gecode/flatzinc/blackbox-propagator.cpp index 127f132b56..7092ec7084 100644 --- a/gecode/flatzinc/blackbox-propagator.cpp +++ b/gecode/flatzinc/blackbox-propagator.cpp @@ -53,7 +53,7 @@ namespace Gecode { namespace FlatZinc { object(backend); } explicit BlackBoxHandle(const SharedHandle& handle) : SharedHandle(handle) {} - BlackBoxHandle(const BlackBoxHandle& handle) : SharedHandle(handle) {} + BlackBoxHandle(const BlackBoxHandle& handle) = default; BlackBoxHandle& operator=(const BlackBoxHandle& handle) { return static_cast(SharedHandle::operator=(handle)); diff --git a/gecode/flatzinc/blackbox.hh b/gecode/flatzinc/blackbox.hh index fdb9d0f69e..734ff8fe7f 100644 --- a/gecode/flatzinc/blackbox.hh +++ b/gecode/flatzinc/blackbox.hh @@ -54,7 +54,7 @@ namespace Gecode { namespace FlatZinc { class BlackBoxContextHandle : public SharedHandle { public: BlackBoxContextHandle(void) : SharedHandle() {} - BlackBoxContextHandle(const BlackBoxContextHandle& handle) : SharedHandle(handle) {} + BlackBoxContextHandle(const BlackBoxContextHandle& handle) = default; BlackBoxContextHandle& operator=(const BlackBoxContextHandle& handle) { return static_cast(SharedHandle::operator=(handle)); diff --git a/gecode/flatzinc/flatzinc.cpp b/gecode/flatzinc/flatzinc.cpp index 8df5d5a098..461c879b2c 100644 --- a/gecode/flatzinc/flatzinc.cpp +++ b/gecode/flatzinc/flatzinc.cpp @@ -288,8 +288,8 @@ namespace Gecode { namespace FlatZinc { BranchInformationO(std::vector v0) : v(std::move(v0)) {} public: - BranchInformationO(void) {} - ~BranchInformationO(void) override {} + BranchInformationO(void) = default; + ~BranchInformationO(void) override = default; virtual SharedHandle::Object* copy(void) const { return new BranchInformationO(v); @@ -317,8 +317,6 @@ namespace Gecode { namespace FlatZinc { BranchInformation::BranchInformation(void) : SharedHandle(nullptr) {} - BranchInformation::BranchInformation(const BranchInformation& bi) : SharedHandle(bi) {} - void BranchInformation::init(void) { assert(object() == nullptr); @@ -792,7 +790,7 @@ namespace Gecode { namespace FlatZinc { BlackBoxContextHandle black_box_context; /// Initialize - FlatZincSpaceInitData(void) {} + FlatZincSpaceInitData(void) = default; }; FlatZincSpace::FlatZincSpace(FlatZincSpace& f) @@ -1780,7 +1778,7 @@ namespace Gecode { namespace FlatZinc { } return ss.str(); } - ~FlatZincGetInfo(void) override {}; + ~FlatZincGetInfo(void) override = default; }; void diff --git a/gecode/flatzinc/parser.hh b/gecode/flatzinc/parser.hh index b02f1152b8..7102c5fdac 100644 --- a/gecode/flatzinc/parser.hh +++ b/gecode/flatzinc/parser.hh @@ -105,6 +105,7 @@ namespace Gecode { namespace FlatZinc { SymbolType t; //< Type of entry int i; //< Value of entry or array start index /// Default constructor + // NOLINTNEXTLINE(modernize-use-equals-default) SymbolEntry(void) {} /// Constructor SymbolEntry(SymbolType t0, int i0) : t(t0), i(i0) {} diff --git a/gecode/flatzinc/varspec.hh b/gecode/flatzinc/varspec.hh index a8682be0a8..f2e43be4dc 100644 --- a/gecode/flatzinc/varspec.hh +++ b/gecode/flatzinc/varspec.hh @@ -51,7 +51,7 @@ namespace Gecode { namespace FlatZinc { class VarSpec { public: /// Destructor - virtual ~VarSpec(void) {} + virtual ~VarSpec(void) = default; /// Variable index int i; /// Whether the variable aliases another variable diff --git a/gecode/float.hh b/gecode/float.hh index 75f539b497..c68a9399f9 100644 --- a/gecode/float.hh +++ b/gecode/float.hh @@ -419,18 +419,18 @@ namespace Gecode { /// \name Constructors and initialization //@{ /// Default constructor - FloatVal(void); + FloatVal(void) = default; /// Initialize with float number \a n FloatVal(const FloatNum& n); /// Initialize with lower bound \a l and upper bound \a u FloatVal(const FloatNum& l, const FloatNum& u); /// Copy constructor - FloatVal(const FloatVal& v); + FloatVal(const FloatVal& v) = default; /// Assignment operator FloatVal& operator=(const FloatNum& n); /// Assignment operator - FloatVal& operator=(const FloatVal& v); + FloatVal& operator=(const FloatVal& v) = default; /// Assign lower bound \a l and upper bound \a u void assign(FloatNum const& l, FloatNum const& u); @@ -874,7 +874,7 @@ namespace Gecode { /// \name Constructors and initialization //@{ /// Default constructor - FloatVar(void); + FloatVar(void) = default; /// Initialize from float variable \a y FloatVar(const FloatVar& y) = default; /// Initialize from float view \a y @@ -974,11 +974,11 @@ namespace Gecode { /// \name Constructors and initialization //@{ /// Allocate empty array - FloatVarArgs(void); + FloatVarArgs(void) = default; /// Allocate array with \a n elements explicit FloatVarArgs(int n); /// Initialize from variable argument array \a a (copy elements) - FloatVarArgs(const FloatVarArgs& a); + FloatVarArgs(const FloatVarArgs& a) = default; /// Initialize from variable array \a a (copy elements) FloatVarArgs(const VarArray& a); /// Initialize from vector \a a @@ -1027,7 +1027,7 @@ namespace Gecode { /// \name Creation and initialization //@{ /// Default constructor (array of size 0) - FloatVarArray(void); + FloatVarArray(void) = default; /// Allocate array for \a n float variables (variables are uninitialized) FloatVarArray(Space& home, int n); /// Initialize from float variable array \a a (share elements) @@ -1451,7 +1451,7 @@ namespace Gecode { * yet initialized AFC storage is init or the assignment operator. * */ - FloatAFC(void); + FloatAFC(void) = default; /** * \brief Initialize for float variables \a x and decay factor \a d * @@ -1493,9 +1493,9 @@ namespace Gecode { * yet initialized action storage is init or the assignment operator. * */ - FloatAction(void); + FloatAction(void) = default; /// Copy constructor - FloatAction(const FloatAction& a); + FloatAction(const FloatAction& a) = default; /// Assignment operator FloatAction& operator=(const FloatAction& a); /** @@ -1548,9 +1548,9 @@ namespace Gecode { * yet initialized CHB storage is init or the assignment operator. * */ - FloatCHB(void); + FloatCHB(void) = default; /// Copy constructor - FloatCHB(const FloatCHB& chb); + FloatCHB(const FloatCHB& chb) = default; /// Assignment operator FloatCHB& operator=(const FloatCHB& chb); /** diff --git a/gecode/float/array.hpp b/gecode/float/array.hpp index cbb9f92aa5..7c04244b24 100644 --- a/gecode/float/array.hpp +++ b/gecode/float/array.hpp @@ -69,17 +69,10 @@ namespace Gecode { FloatValArgs::FloatValArgs(const ArgArray& a) : ArgArray(a) {} - forceinline - FloatVarArgs::FloatVarArgs(void) {} - forceinline FloatVarArgs::FloatVarArgs(int n) : VarArgArray(n) {} - forceinline - FloatVarArgs::FloatVarArgs(const FloatVarArgs& a) - : VarArgArray(a) {} - forceinline FloatVarArgs::FloatVarArgs(const VarArray& a) : VarArgArray(a) {} @@ -97,9 +90,6 @@ namespace Gecode { FloatVarArgs::FloatVarArgs(InputIterator first, InputIterator last) : VarArgArray(first, last) {} - forceinline - FloatVarArray::FloatVarArray(void) {} - forceinline FloatVarArray::FloatVarArray(Space& home, int n) : VarArray(home, n) {} diff --git a/gecode/float/branch/action.hpp b/gecode/float/branch/action.hpp index 0f6f56db08..ea4c46342e 100644 --- a/gecode/float/branch/action.hpp +++ b/gecode/float/branch/action.hpp @@ -32,13 +32,6 @@ namespace Gecode { - forceinline - FloatAction::FloatAction(void) {} - - forceinline - FloatAction::FloatAction(const FloatAction& a) - : Action(a) {} - forceinline FloatAction& FloatAction::operator=(const FloatAction& a) { return static_cast(Action::operator=(a)); diff --git a/gecode/float/branch/afc.hpp b/gecode/float/branch/afc.hpp index 9a105cb9c5..2f74093279 100644 --- a/gecode/float/branch/afc.hpp +++ b/gecode/float/branch/afc.hpp @@ -32,9 +32,6 @@ namespace Gecode { - forceinline - FloatAFC::FloatAFC(void) {} - forceinline FloatAFC::FloatAFC(Home home, const FloatVarArgs& x, double d, bool share) { AFC::init(home, x, d, share); diff --git a/gecode/float/branch/chb.hpp b/gecode/float/branch/chb.hpp index 61f7360881..6144310e2c 100644 --- a/gecode/float/branch/chb.hpp +++ b/gecode/float/branch/chb.hpp @@ -32,13 +32,6 @@ namespace Gecode { - forceinline - FloatCHB::FloatCHB(void) {} - - forceinline - FloatCHB::FloatCHB(const FloatCHB& chb) - : CHB(chb) {} - forceinline FloatCHB& FloatCHB::operator=(const FloatCHB& chb) { return static_cast(CHB::operator=(chb)); diff --git a/gecode/float/trace/trace-view.hpp b/gecode/float/trace/trace-view.hpp index 16a1ef6141..432b5f1c86 100644 --- a/gecode/float/trace/trace-view.hpp +++ b/gecode/float/trace/trace-view.hpp @@ -36,7 +36,7 @@ namespace Gecode { namespace Float { class FloatTraceView { public: /// Default constructor (initializes with no view) - FloatTraceView(void); + FloatTraceView(void) = default; /// Duplicate view \a y FloatTraceView(Space& home, FloatView y); /// Update duplicated view from view \a y and delta \a d @@ -47,8 +47,6 @@ namespace Gecode { namespace Float { static FloatNum slack(FloatView x); }; - forceinline - FloatTraceView::FloatTraceView(void) {} forceinline FloatTraceView::FloatTraceView(Space&, FloatView) {} forceinline void diff --git a/gecode/float/val.hpp b/gecode/float/val.hpp index aa56f141b4..0c726098de 100644 --- a/gecode/float/val.hpp +++ b/gecode/float/val.hpp @@ -41,8 +41,6 @@ namespace Gecode { * */ forceinline - FloatVal::FloatVal(void) {} - forceinline FloatVal::FloatVal(const FloatNum& n) : x(n) {} forceinline @@ -51,20 +49,12 @@ namespace Gecode { forceinline FloatVal::FloatVal(const FloatValImpType& i) : x(i) {} - forceinline - FloatVal::FloatVal(const FloatVal& v) - : x(v.x) {} forceinline FloatVal& FloatVal::operator=(const FloatNum& n) { x = n; return *this; } - forceinline FloatVal& - FloatVal::operator=(const FloatVal& v) { - x = v.x; - return *this; - } forceinline void FloatVal::assign(FloatNum const& l, FloatNum const& u) { diff --git a/gecode/float/var/float.hpp b/gecode/float/var/float.hpp index e7124b56ad..4fce8fb960 100644 --- a/gecode/float/var/float.hpp +++ b/gecode/float/var/float.hpp @@ -39,8 +39,6 @@ namespace Gecode { x = new (home) Float::FloatVarImp(home, FloatVal(min, max)); } - forceinline - FloatVar::FloatVar(void) {} forceinline FloatVar::FloatVar(const Float::FloatView& y) : VarImpVar(y.varimp()) {} diff --git a/gecode/float/view.hpp b/gecode/float/view.hpp index 8f646ddb33..4721968983 100644 --- a/gecode/float/view.hpp +++ b/gecode/float/view.hpp @@ -56,7 +56,7 @@ namespace Gecode { namespace Float { /// \name Constructors and initialization //@{ /// Default constructor - FloatView(void); + FloatView(void) = default; /// Initialize from float variable \a y FloatView(const FloatVar& y); /// Initialize from float variable \a y @@ -158,7 +158,7 @@ namespace Gecode { namespace Float { /// \name Constructors and initialization //@{ /// Default constructor - MinusView(void); + MinusView(void) = default; /// Initialize with float view \a y explicit MinusView(const FloatView& y); //@} @@ -271,7 +271,7 @@ namespace Gecode { namespace Float { /// \name Constructors and initialization //@{ /// Default constructor - OffsetView(void); + OffsetView(void) = default; /// Initialize with float view \a y and an offset c explicit OffsetView(const FloatView& y, FloatNum c); //@} @@ -400,7 +400,7 @@ namespace Gecode { namespace Float { /// \name Constructors and initialization //@{ /// Default constructor - ScaleView(void); + ScaleView(void) = default; /// Initialize as \f$b\cdot y\f$ ScaleView(const FloatVal& b, const FloatView& y); //@} diff --git a/gecode/float/view/float.hpp b/gecode/float/view/float.hpp index 44eb7651dd..cc27997b7c 100644 --- a/gecode/float/view/float.hpp +++ b/gecode/float/view/float.hpp @@ -39,8 +39,6 @@ namespace Gecode { namespace Float { * */ forceinline - FloatView::FloatView(void) {} - forceinline FloatView::FloatView(const FloatVar& y) : VarImpView(y.varimp()) {} forceinline diff --git a/gecode/float/view/minus.hpp b/gecode/float/view/minus.hpp index b9612b9d56..10ca5cbdd9 100644 --- a/gecode/float/view/minus.hpp +++ b/gecode/float/view/minus.hpp @@ -39,8 +39,6 @@ namespace Gecode { namespace Float { * */ forceinline - MinusView::MinusView(void) {} - forceinline MinusView::MinusView(const FloatView& y) : DerivedView(y) {} diff --git a/gecode/float/view/offset.hpp b/gecode/float/view/offset.hpp index d0d6f8e10d..ead5a08560 100644 --- a/gecode/float/view/offset.hpp +++ b/gecode/float/view/offset.hpp @@ -39,8 +39,6 @@ namespace Gecode { namespace Float { * */ forceinline - OffsetView::OffsetView(void) {} - forceinline OffsetView::OffsetView(const FloatView& y, FloatNum d) : DerivedView(y), c(d) {} diff --git a/gecode/float/view/scale.hpp b/gecode/float/view/scale.hpp index 0af370cf7c..6ff5e1052f 100644 --- a/gecode/float/view/scale.hpp +++ b/gecode/float/view/scale.hpp @@ -39,8 +39,6 @@ namespace Gecode { namespace Float { * */ forceinline - ScaleView::ScaleView(void) {} - forceinline ScaleView::ScaleView(const FloatVal& d, const FloatView& y) : DerivedView(y), a(d) {} diff --git a/gecode/gist.hh b/gecode/gist.hh index 26a21ab0a3..4789c9ed88 100644 --- a/gecode/gist.hh +++ b/gecode/gist.hh @@ -264,7 +264,7 @@ namespace Gecode { /// Default options GECODE_GIST_EXPORT static const Options def; /// Initialize with default values - Options(void); + Options(void) = default; }; /// Create a new stand-alone Gist for \a root using \a bab diff --git a/gecode/gist/gist.cpp b/gecode/gist/gist.cpp index f882db2287..2eac8fe6cc 100644 --- a/gecode/gist/gist.cpp +++ b/gecode/gist/gist.cpp @@ -48,7 +48,7 @@ namespace Gecode { namespace Gist { void Inspector::finalize(void) {} - Inspector::~Inspector(void) {} + Inspector::~Inspector(void) = default; std::string Comparator::name(void) { @@ -58,7 +58,7 @@ namespace Gecode { namespace Gist { void Comparator::finalize(void) {} - Comparator::~Comparator(void) {} + Comparator::~Comparator(void) = default; TextOutput::TextOutput(const std::string& name) : t(nullptr), n(name) {} diff --git a/gecode/gist/gist.hpp b/gecode/gist/gist.hpp index fb79e9a0d7..9135e1861e 100644 --- a/gecode/gist/gist.hpp +++ b/gecode/gist/gist.hpp @@ -152,9 +152,6 @@ namespace Gecode { namespace Gist { TextOutput::finalize(); } - forceinline - Options::Options(void) {} - forceinline Options::I_::I_(void) : _click(heap, 1), n_click(0), _solution(heap, 1), n_solution(0), _move(heap, 1), n_move(0), _compare(heap, 1), diff --git a/gecode/gist/visualnode.hh b/gecode/gist/visualnode.hh index f4789a096a..fe944356e6 100644 --- a/gecode/gist/visualnode.hh +++ b/gecode/gist/visualnode.hh @@ -55,7 +55,7 @@ namespace Gecode { namespace Gist { /// Right coordinate int right; /// Default constructor - BoundingBox(void) {} + BoundingBox(void) = default; }; /// \brief %Extent representing shape of a tree at one depth level @@ -87,14 +87,14 @@ namespace Gecode { namespace Gist { BoundingBox bb; /// The shape is an array of extents, one for each depth level Extent shape[1]; + + public: /// Copy constructor - Shape(const Shape&); + Shape(const Shape&) = delete; /// Assignment operator - Shape& operator=(const Shape&); + Shape& operator=(const Shape&) = delete; /// Constructor - Shape(void); - - public: + Shape(void) = delete; /// Construct shape of depth \a d static Shape* allocate(int d); // Destruct diff --git a/gecode/instance/impl.hpp b/gecode/instance/impl.hpp index 3ad9e80e5b..3c7e763e88 100644 --- a/gecode/instance/impl.hpp +++ b/gecode/instance/impl.hpp @@ -479,7 +479,7 @@ namespace Gecode { namespace Instance { /// Value Value value; /// Initialize as the empty integer list without a name - Entry(void) {} + Entry(void) = default; /// Initialize as \a v named \a n Entry(const std::string& n, Value&& v) : name(n), value(std::move(v)) {} }; diff --git a/gecode/int.hh b/gecode/int.hh index ae2cfd7bfd..e626631bea 100644 --- a/gecode/int.hh +++ b/gecode/int.hh @@ -226,7 +226,7 @@ namespace Gecode { /// \name Constructors and initialization //@{ /// Initialize as empty set - IntSet(void); + IntSet(void) = default; /** \brief Initialize as range with minimum \a n and maximum \a m * * Note that the set is empty if \a n is larger than \a m @@ -315,7 +315,7 @@ namespace Gecode { /// \name Constructors and initialization //@{ /// Default constructor - IntSetRanges(void); + IntSetRanges(void) = default; /// Initialize with ranges for set \a s IntSetRanges(const IntSet& s); /// Initialize with ranges for set \a s @@ -351,7 +351,7 @@ namespace Gecode { /// \name Constructors and initialization //@{ /// Default constructor - IntSetValues(void); + IntSetValues(void) = default; /// Initialize with values for \a s IntSetValues(const IntSet& s); /// Initialize with values for \a s @@ -408,7 +408,7 @@ namespace Gecode { /// \name Constructors and initialization //@{ /// Default constructor - IntVar(void); + IntVar(void) = default; /// Initialize from integer variable \a y IntVar(const IntVar& y) = default; /// Initialize from integer view \a y @@ -511,7 +511,7 @@ namespace Gecode { /// \name Constructors and initialization //@{ /// Default constructor - IntVarValues(void); + IntVarValues(void) = default; /// Initialize with values for \a x IntVarValues(const IntVar& x); /// Initialize with values \a x @@ -546,7 +546,7 @@ namespace Gecode { /// \name Constructors and initialization //@{ /// Default constructor - BoolVar(void); + BoolVar(void) = default; /// Initialize from Boolean variable \a y BoolVar(const BoolVar& y) = default; /// Initialize from Boolean view \a y @@ -680,11 +680,11 @@ namespace Gecode { /// \name Constructors and initialization //@{ /// Allocate empty array - IntVarArgs(void); + IntVarArgs(void) = default; /// Allocate array with \a n elements explicit IntVarArgs(int n); /// Initialize from variable argument array \a a (copy elements) - IntVarArgs(const IntVarArgs& a); + IntVarArgs(const IntVarArgs& a) = default; /// Initialize from variable array \a a (copy elements) IntVarArgs(const VarArray& a); /// Initialize from \a a @@ -738,11 +738,11 @@ namespace Gecode { /// \name Constructors and initialization //@{ /// Allocate empty array - BoolVarArgs(void); + BoolVarArgs(void) = default; /// Allocate array with \a n elements explicit BoolVarArgs(int n); /// Initialize from variable argument array \a a (copy elements) - BoolVarArgs(const BoolVarArgs& a); + BoolVarArgs(const BoolVarArgs& a) = default; /// Initialize from variable array \a a (copy elements) BoolVarArgs(const VarArray& a); /// Initialize from \a a @@ -791,7 +791,7 @@ namespace Gecode { /// \name Creation and initialization //@{ /// Default constructor (array of size 0) - IntVarArray(void); + IntVarArray(void) = default; /// Allocate array for \a n integer variables (variables are uninitialized) IntVarArray(Space& home, int n); /// Initialize from integer variable array \a a (share elements) @@ -839,7 +839,7 @@ namespace Gecode { /// \name Creation and initialization //@{ /// Default constructor (array of size 0) - BoolVarArray(void); + BoolVarArray(void) = default; /// Allocate array for \a n Boolean variables (variables are uninitialized) BoolVarArray(Space& home, int n); /// Initialize from Boolean variable array \a a (share elements) @@ -959,7 +959,7 @@ namespace Gecode { */ typedef std::function x, int i)> Transition; /// Construct an uninitialized list - OpenVarList(void); + OpenVarList(void) = default; /// Construct a list using \a create for each position OpenVarList(Space& home, Factory create, int max = Int::Limits::max); /// Construct a list using \a create and transition function \a t @@ -1046,7 +1046,7 @@ namespace Gecode { public: /// Construct an uninitialized list - OpenViewList(void); + OpenViewList(void) = default; /// Share the source of the model list \a list explicit OpenViewList(const OpenVarList& list); /// Update during cloning @@ -1082,7 +1082,7 @@ namespace Gecode { typedef std::function Domain; using OpenVarList::OpenVarList; /// Construct an uninitialized list - GECODE_INT_EXPORT OpenIntVarList(void); + GECODE_INT_EXPORT OpenIntVarList(void) = default; /// Share an integer list constructed through a variable factory OpenIntVarList(const OpenVarList& x); /// Construct a list with maximal length \a max and full domains @@ -1114,7 +1114,7 @@ namespace Gecode { public: using OpenVarList::OpenVarList; /// Construct an uninitialized list - GECODE_INT_EXPORT OpenBoolVarList(void); + GECODE_INT_EXPORT OpenBoolVarList(void) = default; /// Share a Boolean list constructed through a variable factory OpenBoolVarList(const OpenVarList& x); /// Construct a list with maximal length \a max and domains 0..1 @@ -2496,7 +2496,7 @@ namespace Gecode { public: friend class Transitions; /// Initialize for DFA accepting the empty word - DFA(void); + DFA(void) = default; /** * \brief Initialize DFA * @@ -2543,7 +2543,7 @@ namespace Gecode { GECODE_INT_EXPORT static DFA nfa(int s, std::initializer_list t, std::initializer_list f); /// Initialize by DFA \a d (DFA is shared) - DFA(const DFA& d); + DFA(const DFA& d) = default; /// Test whether DFA is equal to \a d GECODE_INT_EXPORT bool operator==(const DFA& d) const; @@ -2781,7 +2781,7 @@ namespace Gecode { /// \name Initialization //@{ /// Construct an uninitialized tuple set - TupleSet(void); + TupleSet(void) = default; /// Initialize for a tuple set with arity \a a GECODE_INT_EXPORT TupleSet(int a); @@ -2790,7 +2790,7 @@ namespace Gecode { void init(int a); /// Initialize by TupleSet \a t (tuple set is shared) GECODE_INT_EXPORT - TupleSet(const TupleSet& t); + TupleSet(const TupleSet& t) = default; /// Assignment operator GECODE_INT_EXPORT TupleSet& operator=(const TupleSet& t); @@ -4924,7 +4924,7 @@ namespace Gecode { * yet initialized AFC storage is init or the assignment operator. * */ - IntAFC(void); + IntAFC(void) = default; /** * \brief Initialize for integer variables \a x and decay factor \a d * @@ -4960,7 +4960,7 @@ namespace Gecode { * yet initialized AFC storage is init or the assignment operator. * */ - BoolAFC(void); + BoolAFC(void) = default; /** * \brief Initialize for Boolean variables \a x and decay factor \a d * @@ -5002,9 +5002,9 @@ namespace Gecode { * yet initialized action storage is init or the assignment operator. * */ - IntAction(void); + IntAction(void) = default; /// Copy constructor - IntAction(const IntAction& a); + IntAction(const IntAction& a) = default; /// Assignment operator IntAction& operator=(const IntAction& a); /** @@ -5050,9 +5050,9 @@ namespace Gecode { * yet initialized action storage is init or the assignment operator. * */ - BoolAction(void); + BoolAction(void) = default; /// Copy constructor - BoolAction(const BoolAction& a); + BoolAction(const BoolAction& a) = default; /// Assignment operator BoolAction& operator=(const BoolAction& a); /** @@ -5104,9 +5104,9 @@ namespace Gecode { * yet initialized CHB storage is init or the assignment operator. * */ - IntCHB(void); + IntCHB(void) = default; /// Copy constructor - IntCHB(const IntCHB& chb); + IntCHB(const IntCHB& chb) = default; /// Assignment operator IntCHB& operator=(const IntCHB& chb); /** @@ -5147,9 +5147,9 @@ namespace Gecode { * yet initialized action storage is init or the assignment operator. * */ - BoolCHB(void); + BoolCHB(void) = default; /// Copy constructor - BoolCHB(const BoolCHB& chb); + BoolCHB(const BoolCHB& chb) = default; /// Assignment operator BoolCHB& operator=(const BoolCHB& chb); /** diff --git a/gecode/int/array.hpp b/gecode/int/array.hpp index 34ad4987d4..3a4eff04e5 100644 --- a/gecode/int/array.hpp +++ b/gecode/int/array.hpp @@ -81,17 +81,10 @@ namespace Gecode { return r; } - forceinline - IntVarArgs::IntVarArgs(void) {} - forceinline IntVarArgs::IntVarArgs(int n) : VarArgArray(n) {} - forceinline - IntVarArgs::IntVarArgs(const IntVarArgs& a) - : VarArgArray(a) {} - forceinline IntVarArgs::IntVarArgs(const VarArray& a) : VarArgArray(a) {} @@ -109,17 +102,10 @@ namespace Gecode { IntVarArgs::IntVarArgs(InputIterator first, InputIterator last) : VarArgArray(first, last) {} - forceinline - BoolVarArgs::BoolVarArgs(void) {} - forceinline BoolVarArgs::BoolVarArgs(int n) : VarArgArray(n) {} - forceinline - BoolVarArgs::BoolVarArgs(const BoolVarArgs& a) - : VarArgArray(a) {} - forceinline BoolVarArgs::BoolVarArgs(const VarArray& a) : VarArgArray(a) {} @@ -137,9 +123,6 @@ namespace Gecode { BoolVarArgs::BoolVarArgs(InputIterator first, InputIterator last) : VarArgArray(first, last) {} - forceinline - IntVarArray::IntVarArray(void) {} - forceinline IntVarArray::IntVarArray(Space& home, int n) : VarArray(home, n) {} @@ -148,9 +131,6 @@ namespace Gecode { IntVarArray::IntVarArray(Space& home, const IntVarArgs& a) : VarArray(home, a) {} - forceinline - BoolVarArray::BoolVarArray(void) {} - forceinline BoolVarArray::BoolVarArray(Space& home, int n) : VarArray(home, n) {} diff --git a/gecode/int/bin-packing.hh b/gecode/int/bin-packing.hh index cd8417ed62..ba24cf4dae 100644 --- a/gecode/int/bin-packing.hh +++ b/gecode/int/bin-packing.hh @@ -96,7 +96,7 @@ namespace Gecode { namespace Int { namespace BinPacking { public: /// Default constructor - SizeSet(void); + SizeSet(void) = default; /// Initialize for at most \a n_max items SizeSet(Region& region, int n_max); /// Add new size \a s @@ -233,7 +233,7 @@ namespace Gecode { namespace Int { namespace BinPacking { class NodeSet : public Support::RawBitSetBase { public: /// Keep uninitialized - NodeSet(void); + NodeSet(void) = default; /// Initialize node set for \a n nodes NodeSet(Region& r, int n); /// Initialize node set as copy of \a ns with \a n nodes @@ -353,7 +353,7 @@ namespace Gecode { namespace Int { namespace BinPacking { /// Return maximal clique found IntSet maximum_clique(void) const; /// Destructor - ~ConflictGraph(void); + ~ConflictGraph(void) = default; }; }}} // namespace Gecode::Int::BinPacking diff --git a/gecode/int/bin-packing/conflict-graph.hpp b/gecode/int/bin-packing/conflict-graph.hpp index 7c24faf457..25f3e13d88 100644 --- a/gecode/int/bin-packing/conflict-graph.hpp +++ b/gecode/int/bin-packing/conflict-graph.hpp @@ -42,8 +42,6 @@ namespace Gecode { namespace Int { namespace BinPacking { return b.size(); } - forceinline - ConflictGraph::NodeSet::NodeSet(void) {} forceinline ConflictGraph::NodeSet::NodeSet(Region& r, int n) : Support::RawBitSetBase(r, static_cast(n)) {} @@ -106,6 +104,7 @@ namespace Gecode { namespace Int { namespace BinPacking { } forceinline + // NOLINTNEXTLINE(modernize-use-equals-default) ConflictGraph::Node::Node(void) {} forceinline @@ -146,8 +145,6 @@ namespace Gecode { namespace Int { namespace BinPacking { } } - forceinline ConflictGraph::~ConflictGraph(void) {} - forceinline void ConflictGraph::edge(int i, int j, bool add) { if (add) { diff --git a/gecode/int/bin-packing/propagate.hpp b/gecode/int/bin-packing/propagate.hpp index 8b6b665826..fc169b48b4 100644 --- a/gecode/int/bin-packing/propagate.hpp +++ b/gecode/int/bin-packing/propagate.hpp @@ -90,8 +90,6 @@ namespace Gecode { namespace Int { namespace BinPacking { * */ forceinline - SizeSet::SizeSet(void) {} - forceinline SizeSet::SizeSet(Region& region, int n_max) : n(0), t(0), s(region.alloc(n_max)) {} forceinline void @@ -113,6 +111,7 @@ namespace Gecode { namespace Int { namespace BinPacking { } forceinline + // NOLINTNEXTLINE(modernize-use-equals-default) SizeSetMinusOne::SizeSetMinusOne(void) {} forceinline SizeSetMinusOne::SizeSetMinusOne(Region& region, int n_max) diff --git a/gecode/int/branch/action.hpp b/gecode/int/branch/action.hpp index f1b9aa564e..af04d2a5b1 100644 --- a/gecode/int/branch/action.hpp +++ b/gecode/int/branch/action.hpp @@ -32,25 +32,11 @@ namespace Gecode { - forceinline - IntAction::IntAction(void) {} - - forceinline - IntAction::IntAction(const IntAction& a) - : Action(a) {} - forceinline IntAction& IntAction::operator=(const IntAction& a) { return static_cast(Action::operator=(a)); } - forceinline - BoolAction::BoolAction(void) {} - - forceinline - BoolAction::BoolAction(const BoolAction& a) - : Action(a) {} - forceinline BoolAction& BoolAction::operator=(const BoolAction& a) { return static_cast(Action::operator=(a)); diff --git a/gecode/int/branch/afc.hpp b/gecode/int/branch/afc.hpp index 7c00fbe441..7a53e6e373 100644 --- a/gecode/int/branch/afc.hpp +++ b/gecode/int/branch/afc.hpp @@ -32,9 +32,6 @@ namespace Gecode { - forceinline - IntAFC::IntAFC(void) {} - forceinline IntAFC::IntAFC(Home home, const IntVarArgs& x, double d, bool share) { AFC::init(home, x, d, share); @@ -45,9 +42,6 @@ namespace Gecode { AFC::init(home, x, d, share); } - forceinline - BoolAFC::BoolAFC(void) {} - forceinline BoolAFC::BoolAFC(Home home, const BoolVarArgs& x, double d, bool share) { AFC::init(home, x, d, share); diff --git a/gecode/int/branch/chb.hpp b/gecode/int/branch/chb.hpp index 69af4cce79..63040c4ac0 100644 --- a/gecode/int/branch/chb.hpp +++ b/gecode/int/branch/chb.hpp @@ -32,25 +32,11 @@ namespace Gecode { - forceinline - IntCHB::IntCHB(void) {} - - forceinline - IntCHB::IntCHB(const IntCHB& chb) - : CHB(chb) {} - forceinline IntCHB& IntCHB::operator=(const IntCHB& chb) { return static_cast(CHB::operator=(chb)); } - forceinline - BoolCHB::BoolCHB(void) {} - - forceinline - BoolCHB::BoolCHB(const BoolCHB& chb) - : CHB(chb) {} - forceinline BoolCHB& BoolCHB::operator=(const BoolCHB& chb) { return static_cast(CHB::operator=(chb)); diff --git a/gecode/int/cumulative/task.hpp b/gecode/int/cumulative/task.hpp index f5f97b28ca..6ff56e3884 100644 --- a/gecode/int/cumulative/task.hpp +++ b/gecode/int/cumulative/task.hpp @@ -39,6 +39,7 @@ namespace Gecode { namespace Int { namespace Cumulative { */ forceinline + // NOLINTNEXTLINE(modernize-use-equals-default) ManFixPTask::ManFixPTask(void) {} forceinline ManFixPTask::ManFixPTask(IntVar s, int p, int c) @@ -84,6 +85,7 @@ namespace Gecode { namespace Int { namespace Cumulative { */ forceinline + // NOLINTNEXTLINE(modernize-use-equals-default) ManFixPSETask::ManFixPSETask(void) {} forceinline ManFixPSETask::ManFixPSETask(TaskType t, IntVar s, int p, int c) @@ -129,6 +131,7 @@ namespace Gecode { namespace Int { namespace Cumulative { */ forceinline + // NOLINTNEXTLINE(modernize-use-equals-default) ManFlexTask::ManFlexTask(void) {} forceinline ManFlexTask::ManFlexTask(IntVar s, IntVar p, IntVar e, int c) @@ -175,6 +178,7 @@ namespace Gecode { namespace Int { namespace Cumulative { */ forceinline + // NOLINTNEXTLINE(modernize-use-equals-default) OptFixPTask::OptFixPTask(void) {} forceinline OptFixPTask::OptFixPTask(IntVar s, int p, int c, BoolVar m) { @@ -207,6 +211,7 @@ namespace Gecode { namespace Int { namespace Cumulative { */ forceinline + // NOLINTNEXTLINE(modernize-use-equals-default) OptFixPSETask::OptFixPSETask(void) {} forceinline OptFixPSETask::OptFixPSETask(TaskType t, IntVar s, int p, int c, BoolVar m) { @@ -239,6 +244,7 @@ namespace Gecode { namespace Int { namespace Cumulative { */ forceinline + // NOLINTNEXTLINE(modernize-use-equals-default) OptFlexTask::OptFlexTask(void) {} forceinline OptFlexTask::OptFlexTask(IntVar s, IntVar p, IntVar e, int c, BoolVar m) { diff --git a/gecode/int/cumulatives/val.hpp b/gecode/int/cumulatives/val.hpp index e9b61f15c9..d99f9ee49d 100644 --- a/gecode/int/cumulatives/val.hpp +++ b/gecode/int/cumulatives/val.hpp @@ -131,6 +131,7 @@ namespace Gecode { namespace Int { namespace Cumulatives { Event(ev_t _e, int _task, int _date, int _inc = 0) : e(_e), task(_task), date(_date), inc(_inc) {} // Default constructor for region-allocated memory + // NOLINTNEXTLINE(modernize-use-equals-default) Event(void) {} /// Order events based on date. diff --git a/gecode/int/distinct.hh b/gecode/int/distinct.hh index 86a86cf0a8..e2c50729fb 100644 --- a/gecode/int/distinct.hh +++ b/gecode/int/distinct.hh @@ -220,7 +220,7 @@ namespace Gecode { namespace Int { namespace Distinct { using ViewValGraph::Graph::scc; using ViewValGraph::Graph::match; /// Construct graph as not yet initialized - Graph(void); + Graph(void) = default; /// Initialize graph ExecStatus init(Space& home, ViewArray& x); /// Mark edges in graph, return true if pruning is at all possible @@ -249,7 +249,7 @@ namespace Gecode { namespace Int { namespace Distinct { public: /// Initialize with non-initialized view-value graph - DomCtrl(void); + DomCtrl(void) = default; /// Check whether a view-value graph is available bool available(void); /// Initialize view-value graph for views \a x diff --git a/gecode/int/distinct/dom-ctrl.hpp b/gecode/int/distinct/dom-ctrl.hpp index 4bee4bd869..476538394b 100644 --- a/gecode/int/distinct/dom-ctrl.hpp +++ b/gecode/int/distinct/dom-ctrl.hpp @@ -39,10 +39,6 @@ namespace Gecode { namespace Int { namespace Distinct { * */ - template - forceinline - DomCtrl::DomCtrl(void) {} - template forceinline bool DomCtrl::available(void) { diff --git a/gecode/int/distinct/graph.hpp b/gecode/int/distinct/graph.hpp index eb7d5d06ff..7dbf432d3b 100644 --- a/gecode/int/distinct/graph.hpp +++ b/gecode/int/distinct/graph.hpp @@ -34,10 +34,6 @@ namespace Gecode { namespace Int { namespace Distinct { - template - forceinline - Graph::Graph(void) {} - template forceinline ExecStatus Graph::init(Space& home, ViewArray& x) { diff --git a/gecode/int/element/view.hpp b/gecode/int/element/view.hpp index 3b42390802..18432ee604 100644 --- a/gecode/int/element/view.hpp +++ b/gecode/int/element/view.hpp @@ -157,7 +157,7 @@ namespace Gecode { namespace Int { namespace Element { const IdxView*cur, *end; public: - IterIdxView(void); + IterIdxView(void) = default; IterIdxView(const IdxView*, const IdxView*); void init(const IdxView*, const IdxView*); bool operator()(void) const; @@ -165,9 +165,6 @@ namespace Gecode { namespace Int { namespace Element { int val(void) const; }; - template - forceinline - IterIdxView::IterIdxView(void) {} template forceinline IterIdxView::IterIdxView(const IdxView* b, const IdxView* e) diff --git a/gecode/int/extensional.hh b/gecode/int/extensional.hh index f7d935a313..fbc63a131d 100644 --- a/gecode/int/extensional.hh +++ b/gecode/int/extensional.hh @@ -125,7 +125,7 @@ namespace Gecode { namespace Int { namespace Extensional { const Support* s2; ///< End of support public: /// Default constructor - LayerValues(void); + LayerValues(void) = default; /// Initialize for support of layer \a l LayerValues(const Layer& l); /// Initialize for support of layer \a l @@ -483,7 +483,7 @@ namespace Gecode { namespace Int { namespace Extensional { /// Initialize with status \a t CompactStatus(StatusType t); /// Copy constructor - CompactStatus(const CompactStatus& status); + CompactStatus(const CompactStatus& status) = default; /// Return status type StatusType type(void) const; /// Test whether only advisor \a a was touched diff --git a/gecode/int/extensional/compact.hpp b/gecode/int/extensional/compact.hpp index 29c66d09a3..5a86cfa0c7 100644 --- a/gecode/int/extensional/compact.hpp +++ b/gecode/int/extensional/compact.hpp @@ -140,11 +140,6 @@ namespace Gecode { namespace Int { namespace Extensional { CompactStatus::CompactStatus(StatusType t) : s(t) {} - template - forceinline - CompactStatus::CompactStatus(const CompactStatus& status) - : s(status.s) {} - template forceinline typename CompactStatus::StatusType CompactStatus::type(void) const { diff --git a/gecode/int/extensional/dfa.hpp b/gecode/int/extensional/dfa.hpp index ada7cb36c2..770c0c9134 100644 --- a/gecode/int/extensional/dfa.hpp +++ b/gecode/int/extensional/dfa.hpp @@ -125,13 +125,6 @@ namespace Gecode { } } - forceinline - DFA::DFA(void) {} - - forceinline - DFA::DFA(const DFA& d) - : SharedHandle(d) {} - forceinline int DFA::n_states(void) const { const DFAI* d = static_cast(object()); @@ -192,6 +185,7 @@ namespace Gecode { */ forceinline + // NOLINTNEXTLINE(modernize-use-equals-default) DFA::Transition::Transition(void) {} forceinline diff --git a/gecode/int/extensional/layered-graph.hpp b/gecode/int/extensional/layered-graph.hpp index 2c00b97613..748c27f64a 100644 --- a/gecode/int/extensional/layered-graph.hpp +++ b/gecode/int/extensional/layered-graph.hpp @@ -118,9 +118,6 @@ namespace Gecode { namespace Int { namespace Extensional { */ template forceinline - LayeredGraph::LayerValues::LayerValues(void) {} - template - forceinline LayeredGraph::LayerValues ::LayerValues(const Layer& l) : s1(l.support), s2(l.support + l.size) {} template diff --git a/gecode/int/extensional/tuple-set.cpp b/gecode/int/extensional/tuple-set.cpp index 13a1d023bd..548c4c2b98 100644 --- a/gecode/int/extensional/tuple-set.cpp +++ b/gecode/int/extensional/tuple-set.cpp @@ -586,7 +586,6 @@ namespace Gecode { TupleSet::init(int a) { object(new Data(a)); } - TupleSet::TupleSet(const TupleSet& ts) : SharedHandle(ts) {} TupleSet& TupleSet::operator=(const TupleSet& ts) { (void)SharedHandle::operator=(ts); diff --git a/gecode/int/extensional/tuple-set.hpp b/gecode/int/extensional/tuple-set.hpp index feb5fa91be..6fdd3fd434 100644 --- a/gecode/int/extensional/tuple-set.hpp +++ b/gecode/int/extensional/tuple-set.hpp @@ -153,9 +153,6 @@ namespace Gecode { return *this; } - forceinline - TupleSet::TupleSet(void) {} - forceinline TupleSet:: operator bool(void) const { return object() != nullptr; diff --git a/gecode/int/gcc/dom-sup.hpp b/gecode/int/gcc/dom-sup.hpp index 9d6209f527..c214f5418a 100644 --- a/gecode/int/gcc/dom-sup.hpp +++ b/gecode/int/gcc/dom-sup.hpp @@ -81,7 +81,7 @@ namespace Gecode { namespace Int { namespace GCC { /// \name Constructors and initialization //@{ /// Default constructor - Node(void); + Node(void) = default; /// Constructor for index \a i that sets type to \a t Node(NodeFlag nf, int i); //@} @@ -139,7 +139,7 @@ namespace Gecode { namespace Int { namespace GCC { /// \name Constructors and initialization //@{ /// Default constructor - VarNode(void); + VarNode(void) = default; /// Creates a variable node with index \a i VarNode(int i); //@} @@ -190,7 +190,7 @@ namespace Gecode { namespace Int { namespace GCC { /// \name Constructors and destructors //@{ /// Default constructor - ValNode(void); + ValNode(void) = default; /** * \brief Constructor for value node * @@ -299,7 +299,7 @@ namespace Gecode { namespace Int { namespace GCC { /// \name Constructors //@{ /// Default constructor - Edge(void) {} + Edge(void) = default; /** * \brief Construct edge \f$e(x,v)\f$ from variable node \a x * and value node \a y @@ -501,8 +501,6 @@ namespace Gecode { namespace Int { namespace GCC { * */ forceinline - Node::Node(void) {} - forceinline Node::Node(NodeFlag nf0, int i) : e(nullptr), fst(nullptr), lst(nullptr), ie(nullptr), idx(i), nf(static_cast(nf0)), noe(0) {} @@ -560,8 +558,6 @@ namespace Gecode { namespace Int { namespace GCC { * Variable nodes * */ - forceinline - VarNode::VarNode(void) {} forceinline VarNode::VarNode(int x) @@ -614,8 +610,6 @@ namespace Gecode { namespace Int { namespace GCC { * Value nodes * */ - forceinline - ValNode::ValNode(void) {} forceinline ValNode::ValNode(int min, int max, int value, int kidx, int kshift, int count) diff --git a/gecode/int/gcc/view.hpp b/gecode/int/gcc/view.hpp index 4f29e970e4..c2737a0f69 100644 --- a/gecode/int/gcc/view.hpp +++ b/gecode/int/gcc/view.hpp @@ -213,6 +213,7 @@ namespace Gecode { namespace Int { * */ forceinline + // NOLINTNEXTLINE(modernize-use-equals-default) CardConst::CardConst(void) {} forceinline void CardConst::init(Space&, int min, int max, int c) { @@ -298,6 +299,7 @@ namespace Gecode { namespace Int { * */ forceinline + // NOLINTNEXTLINE(modernize-use-equals-default) CardView::CardView(void) {} forceinline void CardView::init(const IntView& y, int c) { diff --git a/gecode/int/growable-int-set.hh b/gecode/int/growable-int-set.hh index ee2e428531..f37b377728 100644 --- a/gecode/int/growable-int-set.hh +++ b/gecode/int/growable-int-set.hh @@ -48,6 +48,7 @@ namespace Gecode { namespace Int { struct Range { int min; int max; + // NOLINTNEXTLINE(modernize-use-equals-default) Range(void) {} }; Range* _ranges; @@ -63,10 +64,9 @@ namespace Gecode { namespace Int { /// Add one range, allocating only when a new range is inserted void add(Space& home, int min, int max); + public: GrowableIntSet(const GrowableIntSet&) = delete; GrowableIntSet& operator=(const GrowableIntSet&) = delete; - - public: /// Initialize an empty set GrowableIntSet(void); /// Test membership diff --git a/gecode/int/int-set-1.hpp b/gecode/int/int-set-1.hpp index de033f32e9..b6eff1f0a0 100644 --- a/gecode/int/int-set-1.hpp +++ b/gecode/int/int-set-1.hpp @@ -42,8 +42,6 @@ namespace Gecode { * Integer sets * */ - forceinline - IntSet::IntSet(void) {} /** * \brief Integer set initialization @@ -234,8 +232,6 @@ namespace Gecode { * */ - forceinline - IntSetRanges::IntSetRanges(void) {} forceinline void IntSetRanges::init(const IntSet& s) { int n = s.ranges(); @@ -277,8 +273,6 @@ namespace Gecode { * Value iterator for integer sets * */ - forceinline - IntSetValues::IntSetValues(void) {} forceinline IntSetValues::IntSetValues(const IntSet& s) { diff --git a/gecode/int/ldsb.hh b/gecode/int/ldsb.hh index 9401c4aa81..3afadc851f 100644 --- a/gecode/int/ldsb.hh +++ b/gecode/int/ldsb.hh @@ -285,10 +285,8 @@ namespace Gecode { namespace Int { namespace LDSB { /// position. (Both are zero-based.) int get_val(unsigned int sequence, unsigned int position) const; - private: - ValueSequenceSymmetryImp(const ValueSequenceSymmetryImp&); - public: + ValueSequenceSymmetryImp(const ValueSequenceSymmetryImp&) = delete; /// Constructor for creation ValueSequenceSymmetryImp(Space& home, int* _values, unsigned int n, unsigned int seqsize); /// Copy constructor diff --git a/gecode/int/ldsb/sym-imp.hpp b/gecode/int/ldsb/sym-imp.hpp index 1a545d7714..d02de4d888 100644 --- a/gecode/int/ldsb/sym-imp.hpp +++ b/gecode/int/ldsb/sym-imp.hpp @@ -44,7 +44,7 @@ namespace Gecode { namespace Int { namespace LDSB { } template - SymmetryImp::~SymmetryImp(void) {} + SymmetryImp::~SymmetryImp(void) = default; template void* diff --git a/gecode/int/ldsb/sym-obj.cpp b/gecode/int/ldsb/sym-obj.cpp index f7b95ccf87..515e6a6334 100644 --- a/gecode/int/ldsb/sym-obj.cpp +++ b/gecode/int/ldsb/sym-obj.cpp @@ -70,7 +70,7 @@ namespace Gecode { namespace Gecode { namespace Int { namespace LDSB { SymmetryObject::SymmetryObject(void) : nrefs(1) {} - SymmetryObject::~SymmetryObject(void) {} + SymmetryObject::~SymmetryObject(void) = default; VariableSymmetryObject::VariableSymmetryObject(ArgArray vars) { nxs = vars.size(); diff --git a/gecode/int/linear.hh b/gecode/int/linear.hh index c855660b20..e9453191fd 100644 --- a/gecode/int/linear.hh +++ b/gecode/int/linear.hh @@ -1163,7 +1163,7 @@ namespace Gecode { namespace Int { namespace Linear { public: /// Default constructor - ScaleBoolArray(void); + ScaleBoolArray(void) = default; /// Create array with \a n elements ScaleBoolArray(Space& home, int n); /// Subscribe propagator \a p @@ -1203,7 +1203,7 @@ namespace Gecode { namespace Int { namespace Linear { class EmptyScaleBoolArray { public: /// Default constructor - EmptyScaleBoolArray(void); + EmptyScaleBoolArray(void) = default; /// Create array with \a n elements EmptyScaleBoolArray(Space& home, int n); /// Subscribe propagator \a p diff --git a/gecode/int/linear/bool-scale.hpp b/gecode/int/linear/bool-scale.hpp index e48e597f93..a623387f84 100644 --- a/gecode/int/linear/bool-scale.hpp +++ b/gecode/int/linear/bool-scale.hpp @@ -37,8 +37,6 @@ namespace Gecode { namespace Int { namespace Linear { * */ forceinline - ScaleBoolArray::ScaleBoolArray(void) {} - forceinline ScaleBoolArray::ScaleBoolArray(Space& home, int n) { if (n > 0) { _fst = home.alloc(n); @@ -116,8 +114,6 @@ namespace Gecode { namespace Int { namespace Linear { * */ forceinline - EmptyScaleBoolArray::EmptyScaleBoolArray(void) {} - forceinline EmptyScaleBoolArray::EmptyScaleBoolArray(Space&, int) {} forceinline void EmptyScaleBoolArray::subscribe(Space&, Propagator&) {} diff --git a/gecode/int/linear/int-dom.hpp b/gecode/int/linear/int-dom.hpp index 39ec9c70b9..ad89368707 100644 --- a/gecode/int/linear/int-dom.hpp +++ b/gecode/int/linear/int-dom.hpp @@ -46,7 +46,7 @@ namespace Gecode { namespace Int { namespace Linear { public: /// Default constructor - SupportSet(void); + SupportSet(void) = default; /// Initialize support set with cardinality \a n void init(Region& r, unsigned int n); /// Record that there is support at position \a i @@ -160,8 +160,6 @@ namespace Gecode { namespace Int { namespace Linear { * Support set * */ - forceinline - SupportSet::SupportSet(void) {} forceinline void SupportSet::init(Region& r, unsigned int n) { bs.init(r, n); diff --git a/gecode/int/linear/int-noview.hpp b/gecode/int/linear/int-noview.hpp index 9706c6dce4..e541df4694 100644 --- a/gecode/int/linear/int-noview.hpp +++ b/gecode/int/linear/int-noview.hpp @@ -43,7 +43,7 @@ namespace Gecode { /// \name Constructors and initialization //@{ /// Default constructor - NoView(void) {} + NoView(void) = default; //@} /// \name Value access @@ -229,14 +229,14 @@ namespace Gecode { /// \name Constructors and initialization //@{ /// Default constructor (array of size 0) - ViewArray(void) {} + ViewArray(void) = default; /// Allocate array with \a m variables ViewArray(Space& home, int m) { (void)home; (void)m; } /// Initialize - ViewArray(const ViewArray&) {} + ViewArray(const ViewArray&) = default; /// Initialize ViewArray(Space&, const ViewArray&) {} /// Initialize @@ -326,9 +326,8 @@ namespace Gecode { (void)i; } //@} - private: - static void* operator new(size_t); - static void operator delete(void*, size_t); + static void* operator new(size_t) = delete; + static void operator delete(void*, size_t) = delete; }; } // namespace Gecode diff --git a/gecode/int/min-distance.cpp b/gecode/int/min-distance.cpp index 9360ba6f87..33ce97f446 100644 --- a/gecode/int/min-distance.cpp +++ b/gecode/int/min-distance.cpp @@ -40,7 +40,7 @@ namespace Gecode { IntDistance::Data::Data(int n0, std::function f) : n(n0), function(std::move(f)) {} - IntDistance::Data::~Data(void) {} + IntDistance::Data::~Data(void) = default; IntDistance::IntDistance(int n, const IntArgs& matrix) { Int::Limits::positive(n, "IntDistance"); diff --git a/gecode/int/no-overlap.hh b/gecode/int/no-overlap.hh index 8c9c8aaceb..2082cc6630 100644 --- a/gecode/int/no-overlap.hh +++ b/gecode/int/no-overlap.hh @@ -107,7 +107,7 @@ namespace Gecode { namespace Int { namespace NoOverlap { public: /// Default constructor - FlexDim(void); + FlexDim(void) = default; /// Constructor FlexDim(IntView c0, IntView s, IntView c1); diff --git a/gecode/int/no-overlap/dim.hpp b/gecode/int/no-overlap/dim.hpp index da7e8d9df8..e2b2598bd3 100644 --- a/gecode/int/no-overlap/dim.hpp +++ b/gecode/int/no-overlap/dim.hpp @@ -114,8 +114,6 @@ namespace Gecode { namespace Int { namespace NoOverlap { * */ forceinline - FlexDim::FlexDim(void) {} - forceinline FlexDim::FlexDim(IntView c00, IntView s0, IntView c10) : c0(c00), s(s0), c1(c10) {} diff --git a/gecode/int/open-var-list.cpp b/gecode/int/open-var-list.cpp index ec2138c0c7..d3e3da1fc4 100644 --- a/gecode/int/open-var-list.cpp +++ b/gecode/int/open-var-list.cpp @@ -34,8 +34,6 @@ namespace Gecode { - OpenIntVarList::OpenIntVarList(void) {} - OpenIntVarList::Factory OpenIntVarList::factory(Domain d) { if (!d) @@ -58,8 +56,6 @@ namespace Gecode { OpenIntVarList::OpenIntVarList(Space& home, Domain d, Transition t, int max) : OpenVarList(home, factory(std::move(d)), std::move(t), max) {} - OpenBoolVarList::OpenBoolVarList(void) {} - OpenBoolVarList::OpenBoolVarList(Space& home, int max) : OpenVarList(home, [](Space& home, int) { return BoolVar(home, 0, 1); }, max) {} diff --git a/gecode/int/open-var-list.hpp b/gecode/int/open-var-list.hpp index 0d21853a0c..518a0b9752 100644 --- a/gecode/int/open-var-list.hpp +++ b/gecode/int/open-var-list.hpp @@ -274,9 +274,6 @@ namespace Gecode { namespace Int { namespace Gecode { - template - OpenVarList::OpenVarList(void) {} - template OpenVarList::OpenVarList(Object* source) : LocalHandle(source) {} @@ -407,9 +404,6 @@ namespace Gecode { namespace Int { namespace Gecode { - template - OpenViewList::OpenViewList(void) {} - template OpenViewList::OpenViewList(const OpenVarList& list) : LocalHandle(list) {} diff --git a/gecode/int/task.hh b/gecode/int/task.hh index fe449514d9..22d940a769 100644 --- a/gecode/int/task.hh +++ b/gecode/int/task.hh @@ -48,7 +48,7 @@ namespace Gecode { namespace Int { /// \name Constructors and initialization //@{ /// Default constructor - ManToOptTask(void); + ManToOptTask(void) = default; //@} /// \name Value access @@ -214,9 +214,9 @@ namespace Gecode { namespace Int { void update(Space&, TaskArray& a); //@} - private: - static void* operator new(size_t); - static void operator delete(void*, size_t); + public: + static void* operator new(size_t) = delete; + static void operator delete(void*, size_t) = delete; }; /** @@ -257,9 +257,9 @@ namespace Gecode { namespace Int { /// Return task view at position \a i const TaskView& operator[](int i) const; //@} - private: - static void* operator new(size_t); - static void operator delete(void*, size_t); + public: + static void* operator new(size_t) = delete; + static void operator delete(void*, size_t) = delete; }; /** @@ -311,7 +311,7 @@ namespace Gecode { namespace Int { /// Current position int i; /// Default constructor (no initialization) - TaskViewIter(void); + TaskViewIter(void) = default; public: /// Initialize iterator diff --git a/gecode/int/task/iter.hpp b/gecode/int/task/iter.hpp index f725749d11..d8371fe5eb 100644 --- a/gecode/int/task/iter.hpp +++ b/gecode/int/task/iter.hpp @@ -34,10 +34,6 @@ namespace Gecode { namespace Int { - template - forceinline - TaskViewIter::TaskViewIter(void) {} - template forceinline TaskViewIter::TaskViewIter(Region& r, const TaskViewArray& t) diff --git a/gecode/int/task/man-to-opt.hpp b/gecode/int/task/man-to-opt.hpp index 5b5586d2e3..7da078d361 100644 --- a/gecode/int/task/man-to-opt.hpp +++ b/gecode/int/task/man-to-opt.hpp @@ -32,10 +32,6 @@ namespace Gecode { namespace Int { - template - forceinline - ManToOptTask::ManToOptTask(void) {} - template forceinline bool ManToOptTask::mandatory(void) const { diff --git a/gecode/int/trace/bool-trace-view.hpp b/gecode/int/trace/bool-trace-view.hpp index 0c5cbb193b..2eab86ef5a 100644 --- a/gecode/int/trace/bool-trace-view.hpp +++ b/gecode/int/trace/bool-trace-view.hpp @@ -36,7 +36,7 @@ namespace Gecode { namespace Int { class BoolTraceView { public: /// Default constructor (initializes with no view) - BoolTraceView(void); + BoolTraceView(void) = default; /// Duplicate view \a y BoolTraceView(Space& home, BoolView y); /// Update duplicated view from view \a y and modification delta \a d @@ -47,8 +47,6 @@ namespace Gecode { namespace Int { static unsigned int slack(BoolView x); }; - forceinline - BoolTraceView::BoolTraceView(void) {} forceinline BoolTraceView::BoolTraceView(Space&, BoolView) {} forceinline void diff --git a/gecode/int/trace/int-trace-view.hpp b/gecode/int/trace/int-trace-view.hpp index 448e0edfa0..52fc21f178 100644 --- a/gecode/int/trace/int-trace-view.hpp +++ b/gecode/int/trace/int-trace-view.hpp @@ -54,6 +54,7 @@ namespace Gecode { namespace Int { }; forceinline + // NOLINTNEXTLINE(modernize-use-equals-default) IntTraceView::IntTraceView(void) {} forceinline diff --git a/gecode/int/unary.hh b/gecode/int/unary.hh index ced0bd268a..080d8bd96f 100644 --- a/gecode/int/unary.hh +++ b/gecode/int/unary.hh @@ -277,7 +277,7 @@ namespace Gecode { namespace Int { namespace Unary { /// \name Constructors and initialization //@{ /// Default constructor - ManFlexTask(void); + ManFlexTask(void) = default; /// Initialize with start time \a s, processing time \a p, end time \a e ManFlexTask(IntVar s, IntVar p, IntVar e); /// Initialize with start time \a s, processing time \a p, end time \a e @@ -371,7 +371,7 @@ namespace Gecode { namespace Int { namespace Unary { /// \name Constructors and initialization //@{ /// Default constructor - OptFlexTask(void); + OptFlexTask(void) = default; /// Initialize with start time \a s, processing time \a p, end time \a e, and mandatory flag \a m OptFlexTask(IntVar s, IntVar p, IntVar e, BoolVar m); /// Initialize with start time \a s, processing time \a p, end time \a e, and mandatory flag \a m diff --git a/gecode/int/unary/task.hpp b/gecode/int/unary/task.hpp index c7c206ae02..e5af995744 100644 --- a/gecode/int/unary/task.hpp +++ b/gecode/int/unary/task.hpp @@ -52,6 +52,7 @@ namespace Gecode { namespace Int { namespace Unary { */ forceinline + // NOLINTNEXTLINE(modernize-use-equals-default) ManFixPTask::ManFixPTask(void) {} forceinline ManFixPTask::ManFixPTask(IntVar s, int p) @@ -183,6 +184,7 @@ namespace Gecode { namespace Int { namespace Unary { */ forceinline + // NOLINTNEXTLINE(modernize-use-equals-default) ManFixPSETask::ManFixPSETask(void) {} forceinline ManFixPSETask::ManFixPSETask(TaskType t, IntVar s, int p) @@ -362,8 +364,6 @@ namespace Gecode { namespace Int { namespace Unary { * Mandatory flexible task */ - forceinline - ManFlexTask::ManFlexTask(void) {} forceinline ManFlexTask::ManFlexTask(IntVar s, IntVar p, IntVar e) : _s(s), _p(p), _e(e) {} @@ -515,6 +515,7 @@ namespace Gecode { namespace Int { namespace Unary { */ forceinline + // NOLINTNEXTLINE(modernize-use-equals-default) OptFixPTask::OptFixPTask(void) {} forceinline OptFixPTask::OptFixPTask(IntVar s, int p, BoolVar m) { @@ -542,6 +543,7 @@ namespace Gecode { namespace Int { namespace Unary { */ forceinline + // NOLINTNEXTLINE(modernize-use-equals-default) OptFixPSETask::OptFixPSETask(void) {} forceinline OptFixPSETask::OptFixPSETask(TaskType t, IntVar s, int p, BoolVar m) { @@ -568,8 +570,6 @@ namespace Gecode { namespace Int { namespace Unary { * Optional flexible task */ - forceinline - OptFlexTask::OptFlexTask(void) {} forceinline OptFlexTask::OptFlexTask(IntVar s, IntVar p, IntVar e, BoolVar m) { ManFlexTask::init(s, p, e); diff --git a/gecode/int/var-imp.hpp b/gecode/int/var-imp.hpp index 59fec94699..e7be318608 100644 --- a/gecode/int/var-imp.hpp +++ b/gecode/int/var-imp.hpp @@ -403,7 +403,7 @@ namespace Gecode { namespace Int { /// \name Constructors and initialization //@{ /// Default constructor - IntVarImpFwd(void); + IntVarImpFwd(void) = default; /// Initialize with ranges from variable implementation \a x IntVarImpFwd(const IntVarImp* x); /// Initialize with ranges from variable implementation \a x @@ -447,7 +447,7 @@ namespace Gecode { namespace Int { /// \name Constructors and initialization //@{ /// Default constructor - IntVarImpBwd(void); + IntVarImpBwd(void) = default; /// Initialize with ranges from variable implementation \a x IntVarImpBwd(const IntVarImp* x); /// Initialize with ranges from variable implementation \a x diff --git a/gecode/int/var-imp/int.hpp b/gecode/int/var-imp/int.hpp index 1e41f8b933..56b2a0b7e7 100644 --- a/gecode/int/var-imp/int.hpp +++ b/gecode/int/var-imp/int.hpp @@ -52,6 +52,7 @@ namespace Gecode { namespace Int { } forceinline + // NOLINTNEXTLINE(modernize-use-equals-default) IntVarImp::RangeList::RangeList(void) {} forceinline @@ -423,8 +424,6 @@ namespace Gecode { namespace Int { * */ - forceinline - IntVarImpFwd::IntVarImpFwd(void) {} forceinline IntVarImpFwd::IntVarImpFwd(const IntVarImp* x) : p(nullptr), c(x->ranges_fwd()) {} @@ -463,8 +462,6 @@ namespace Gecode { namespace Int { * */ - forceinline - IntVarImpBwd::IntVarImpBwd(void) {} forceinline IntVarImpBwd::IntVarImpBwd(const IntVarImp* x) : n(nullptr), c(x->ranges_bwd()) {} diff --git a/gecode/int/var/bool.hpp b/gecode/int/var/bool.hpp index be548ae677..72c16c9b38 100644 --- a/gecode/int/var/bool.hpp +++ b/gecode/int/var/bool.hpp @@ -43,8 +43,6 @@ namespace Gecode { x = new (home) Int::BoolVarImp(home, 0, 1); } - forceinline - BoolVar::BoolVar(void) {} forceinline BoolVar::BoolVar(const Int::BoolView& y) : VarImpVar(y.varimp()) {} diff --git a/gecode/int/var/int.hpp b/gecode/int/var/int.hpp index 1130dd6f89..34932bcab5 100644 --- a/gecode/int/var/int.hpp +++ b/gecode/int/var/int.hpp @@ -42,8 +42,6 @@ namespace Gecode { x = new (home) Int::IntVarImp(home, ds); } - forceinline - IntVar::IntVar(void) {} forceinline IntVar::IntVar(const Int::IntView& y) : VarImpVar(y.varimp()) {} @@ -98,6 +96,7 @@ namespace Gecode { * */ forceinline + // NOLINTNEXTLINE(modernize-use-equals-default) IntVarRanges::IntVarRanges(void) {} forceinline @@ -114,9 +113,6 @@ namespace Gecode { * */ - forceinline - IntVarValues::IntVarValues(void) {} - forceinline IntVarValues::IntVarValues(const IntVar& x) { IntVarRanges r(x); diff --git a/gecode/int/view.hpp b/gecode/int/view.hpp index 589e3e95bd..6711746abd 100644 --- a/gecode/int/view.hpp +++ b/gecode/int/view.hpp @@ -95,7 +95,7 @@ namespace Gecode { namespace Int { /// \name Constructors and initialization //@{ /// Default constructor - ViewValues(void); + ViewValues(void) = default; /// Initialize with values for \a x ViewValues(const View& x); /// Initialize with values \a x @@ -133,7 +133,7 @@ namespace Gecode { namespace Int { /// \name Constructors and initialization //@{ /// Default constructor - IntView(void); + IntView(void) = default; /// Initialize from integer variable \a y IntView(const IntVar& y); /// Initialize from integer variable \a y @@ -285,7 +285,7 @@ namespace Gecode { namespace Int { /// \name Constructors and initialization //@{ /// Default constructor - MinusView(void); + MinusView(void) = default; /// Initialize with integer view \a y explicit MinusView(const IntView& y); //@} @@ -1011,7 +1011,7 @@ namespace Gecode { namespace Int { /// \name Constructors and initialization //@{ /// Default constructor - ZeroIntView(void); + ZeroIntView(void) = default; //@} /// \name Value access @@ -1358,7 +1358,7 @@ namespace Gecode { namespace Int { /// \name Constructors and initialization //@{ /// Default constructor - ViewDiffRanges(void); + ViewDiffRanges(void) = default; /// Initialize with ranges for view \a x ViewDiffRanges(const CachedView& x); /// Initialize with ranges for view \a x @@ -1380,7 +1380,7 @@ namespace Gecode { namespace Int { /// \name Constructors and initialization //@{ /// Default constructor - BoolView(void); + BoolView(void) = default; /// Initialize from Boolean variable \a y BoolView(const BoolVar& y); /// Initialize from Boolean variable implementation \a y @@ -1572,7 +1572,7 @@ namespace Gecode { namespace Int { /// \name Constructors and initialization //@{ /// Default constructor - NegBoolView(void); + NegBoolView(void) = default; /// Initialize with Boolean view \a y explicit NegBoolView(const BoolView& y); //@} diff --git a/gecode/int/view/bool.hpp b/gecode/int/view/bool.hpp index 3012a86e64..c64b4f1a7d 100644 --- a/gecode/int/view/bool.hpp +++ b/gecode/int/view/bool.hpp @@ -41,8 +41,6 @@ namespace Gecode { namespace Int { * */ forceinline - BoolView::BoolView(void) {} - forceinline BoolView::BoolView(const BoolVar& y) : VarImpView(y.varimp()) {} forceinline @@ -290,7 +288,7 @@ namespace Gecode { namespace Int { /// \name Constructors and initialization //@{ /// Default constructor - ViewRanges(void); + ViewRanges(void) = default; /// Initialize with ranges for view \a x ViewRanges(const BoolView& x); /// Initialize with ranges for view \a x @@ -298,9 +296,6 @@ namespace Gecode { namespace Int { //@} }; - forceinline - ViewRanges::ViewRanges(void) {} - forceinline ViewRanges::ViewRanges(const BoolView& x) : Iter::Ranges::Singleton(x.min(), x.max()) {} diff --git a/gecode/int/view/cached.hpp b/gecode/int/view/cached.hpp index 741d5d418c..1e9386175e 100644 --- a/gecode/int/view/cached.hpp +++ b/gecode/int/view/cached.hpp @@ -334,7 +334,7 @@ namespace Gecode { namespace Int { /// \name Constructors and initialization //@{ /// Default constructor - ViewRanges(void); + ViewRanges(void) = default; /// Initialize with ranges for view \a x ViewRanges(const CachedView& x); /// Initialize with ranges for view \a x @@ -342,10 +342,6 @@ namespace Gecode { namespace Int { //@} }; - template - forceinline - ViewRanges>::ViewRanges(void) {} - template forceinline ViewRanges>::ViewRanges(const CachedView& x) { @@ -358,10 +354,6 @@ namespace Gecode { namespace Int { ViewRanges::init(x.base()); } - template - forceinline - ViewDiffRanges::ViewDiffRanges(void) {} - template forceinline ViewDiffRanges::ViewDiffRanges(const CachedView& x) diff --git a/gecode/int/view/constint.hpp b/gecode/int/view/constint.hpp index edc200396c..a26d5d3463 100644 --- a/gecode/int/view/constint.hpp +++ b/gecode/int/view/constint.hpp @@ -37,6 +37,7 @@ namespace Gecode { namespace Int { * */ forceinline + // NOLINTNEXTLINE(modernize-use-equals-default) ConstIntView::ConstIntView(void) {} forceinline ConstIntView::ConstIntView(int n) @@ -252,7 +253,7 @@ namespace Gecode { namespace Int { /// \name Constructors and initialization //@{ /// Default constructor - ViewRanges(void); + ViewRanges(void) = default; /// Initialize with ranges for view \a x ViewRanges(const ConstIntView& x); /// Initialize with ranges for view \a x @@ -278,9 +279,6 @@ namespace Gecode { namespace Int { //@} }; - forceinline - ViewRanges::ViewRanges(void) {} - forceinline ViewRanges::ViewRanges(const ConstIntView& x) : n(x.val()) {} diff --git a/gecode/int/view/int.hpp b/gecode/int/view/int.hpp index 793f95bbb6..0becb7d596 100644 --- a/gecode/int/view/int.hpp +++ b/gecode/int/view/int.hpp @@ -41,8 +41,6 @@ namespace Gecode { namespace Int { * */ forceinline - IntView::IntView(void) {} - forceinline IntView::IntView(const IntVar& y) : VarImpView(y.varimp()) {} forceinline @@ -248,6 +246,7 @@ namespace Gecode { namespace Int { }; forceinline + // NOLINTNEXTLINE(modernize-use-equals-default) ViewRanges::ViewRanges(void) {} forceinline diff --git a/gecode/int/view/iter.hpp b/gecode/int/view/iter.hpp index 6a8d38c87e..d1c4b6df6e 100644 --- a/gecode/int/view/iter.hpp +++ b/gecode/int/view/iter.hpp @@ -36,10 +36,6 @@ namespace Gecode { namespace Int { - template - forceinline - ViewValues::ViewValues(void) {} - template forceinline ViewValues::ViewValues(const View& x) { diff --git a/gecode/int/view/minus.hpp b/gecode/int/view/minus.hpp index 224876ee8d..d34b81f39e 100644 --- a/gecode/int/view/minus.hpp +++ b/gecode/int/view/minus.hpp @@ -41,8 +41,6 @@ namespace Gecode { namespace Int { * */ forceinline - MinusView::MinusView(void) {} - forceinline MinusView::MinusView(const IntView& y) : DerivedView(y) {} @@ -265,6 +263,7 @@ namespace Gecode { namespace Int { }; forceinline + // NOLINTNEXTLINE(modernize-use-equals-default) ViewRanges::ViewRanges(void) {} forceinline diff --git a/gecode/int/view/neg-bool.hpp b/gecode/int/view/neg-bool.hpp index 818ced496b..a56b261b4c 100644 --- a/gecode/int/view/neg-bool.hpp +++ b/gecode/int/view/neg-bool.hpp @@ -46,8 +46,6 @@ namespace Gecode { namespace Int { * */ forceinline - NegBoolView::NegBoolView(void) {} - forceinline NegBoolView::NegBoolView(const BoolView& y) : DerivedView(y) {} @@ -222,7 +220,7 @@ namespace Gecode { namespace Int { /// \name Constructors and initialization //@{ /// Default constructor - ViewRanges(void); + ViewRanges(void) = default; /// Initialize with ranges for view \a x ViewRanges(const NegBoolView& x); /// Initialize with ranges for view \a x @@ -230,9 +228,6 @@ namespace Gecode { namespace Int { //@} }; - forceinline - ViewRanges::ViewRanges(void) {} - forceinline ViewRanges::ViewRanges(const NegBoolView& x) : Iter::Ranges::Singleton(x.min(), x.max()) {} diff --git a/gecode/int/view/offset.hpp b/gecode/int/view/offset.hpp index 5c433eb394..b7bffc1121 100644 --- a/gecode/int/view/offset.hpp +++ b/gecode/int/view/offset.hpp @@ -41,6 +41,7 @@ namespace Gecode { namespace Int { * */ forceinline + // NOLINTNEXTLINE(modernize-use-equals-default) OffsetView::OffsetView(void) {} forceinline OffsetView::OffsetView(const IntView& y, int d) @@ -273,7 +274,7 @@ namespace Gecode { namespace Int { /// \name Constructors and initialization //@{ /// Default constructor - ViewRanges(void); + ViewRanges(void) = default; /// Initialize with ranges for view \a x ViewRanges(const OffsetView& x); /// Initialize with ranges for view \a x @@ -281,9 +282,6 @@ namespace Gecode { namespace Int { //@} }; - forceinline - ViewRanges::ViewRanges(void) {} - forceinline ViewRanges::ViewRanges(const OffsetView& x) { ViewRanges xi(x.base()); diff --git a/gecode/int/view/scale.hpp b/gecode/int/view/scale.hpp index ffe974caca..018dde0a17 100644 --- a/gecode/int/view/scale.hpp +++ b/gecode/int/view/scale.hpp @@ -44,6 +44,7 @@ namespace Gecode { namespace Int { */ template forceinline + // NOLINTNEXTLINE(modernize-use-equals-default) ScaleView::ScaleView(void) {} template @@ -235,7 +236,7 @@ namespace Gecode { namespace Int { /// \name Constructors and initialization //@{ /// Default constructor - ViewRanges(void); + ViewRanges(void) = default; /// Initialize with ranges for view \a x ViewRanges(const IntScaleView& x); /// Initialize with ranges for view \a x @@ -243,8 +244,6 @@ namespace Gecode { namespace Int { //@} }; - forceinline - ViewRanges::ViewRanges(void) {} forceinline ViewRanges::ViewRanges(const IntScaleView& x) { ViewRanges xi(x.base()); @@ -267,7 +266,7 @@ namespace Gecode { namespace Int { /// \name Constructors and initialization //@{ /// Default constructor - ViewRanges(void); + ViewRanges(void) = default; /// Initialize with ranges for view \a x ViewRanges(const LLongScaleView& x); /// Initialize with ranges for view \a x @@ -275,8 +274,6 @@ namespace Gecode { namespace Int { //@} }; - forceinline - ViewRanges::ViewRanges(void) {} forceinline ViewRanges::ViewRanges(const LLongScaleView& x) { ViewRanges xi(x.base()); diff --git a/gecode/int/view/zero.hpp b/gecode/int/view/zero.hpp index 3689671916..ced621fb44 100644 --- a/gecode/int/view/zero.hpp +++ b/gecode/int/view/zero.hpp @@ -36,8 +36,6 @@ namespace Gecode { namespace Int { * Constructors and initialization * */ - forceinline - ZeroIntView::ZeroIntView(void) {} /* * Value access @@ -230,7 +228,7 @@ namespace Gecode { namespace Int { /// \name Constructors and initialization //@{ /// Default constructor - ViewRanges(void); + ViewRanges(void) = default; /// Initialize with ranges for view \a x ViewRanges(const ZeroIntView& x); /// Initialize with ranges for view \a x @@ -256,9 +254,6 @@ namespace Gecode { namespace Int { //@} }; - forceinline - ViewRanges::ViewRanges(void) {} - forceinline ViewRanges::ViewRanges(const ZeroIntView&) : done(false) {} diff --git a/gecode/iter/ranges-add.hpp b/gecode/iter/ranges-add.hpp index bc589320ae..e12f824c79 100644 --- a/gecode/iter/ranges-add.hpp +++ b/gecode/iter/ranges-add.hpp @@ -51,7 +51,7 @@ namespace Gecode { namespace Iter { namespace Ranges { /// \name Constructors and initialization //@{ /// Default constructor - AddRange(void); + AddRange(void) = default; /// Initialize with ranges \a i and range \a min to \a max AddRange(I& i, int min, int max); /// Initialize with ranges \a i and range \a min to \a max @@ -76,7 +76,7 @@ namespace Gecode { namespace Iter { namespace Ranges { /// \name Constructors and initialization //@{ /// Default constructor - SubRange(void); + SubRange(void) = default; /// Initialize with ranges \a i and range \a min to \a max SubRange(I& i, int min, int max); /// Initialize with ranges \a i and range \a min to \a max @@ -84,10 +84,6 @@ namespace Gecode { namespace Iter { namespace Ranges { //@} }; - template - forceinline - AddRange::AddRange(void) {} - template forceinline void AddRange::operator++(void) { @@ -120,10 +116,6 @@ namespace Gecode { namespace Iter { namespace Ranges { operator++(); } - template - forceinline - SubRange::SubRange(void) {} - template forceinline SubRange::SubRange(I& i, int r_min, int r_max) diff --git a/gecode/iter/ranges-append.hpp b/gecode/iter/ranges-append.hpp index b1ed45c85e..c305531533 100644 --- a/gecode/iter/ranges-append.hpp +++ b/gecode/iter/ranges-append.hpp @@ -53,7 +53,7 @@ namespace Gecode { namespace Iter { namespace Ranges { /// \name Constructors and initialization //@{ /// Default constructor - Append(void); + Append(void) = default; /// Initialize with iterator \a i and \a j Append(I& i, J& j); /// Initialize with iterator \a i and \a j @@ -90,7 +90,7 @@ namespace Gecode { namespace Iter { namespace Ranges { /// \name Constructors and initialization //@{ /// Default constructor - NaryAppend(void); + NaryAppend(void) = default; /// Initialize with \a n iterators in \a i NaryAppend(I* i, int n); /// Initialize with \a n iterators in \a i @@ -129,10 +129,6 @@ namespace Gecode { namespace Iter { namespace Ranges { } } - template - forceinline - Append::Append(void) {} - template forceinline Append::Append(I& i0, J& j0) @@ -183,10 +179,6 @@ namespace Gecode { namespace Iter { namespace Ranges { } } - template - forceinline - NaryAppend::NaryAppend(void) {} - template inline NaryAppend::NaryAppend(I* r0, int n0) : r(r0), n(n0), active(0) { while (active < n && !r[active]()) diff --git a/gecode/iter/ranges-array.hpp b/gecode/iter/ranges-array.hpp index ba02abce89..97c92541a1 100644 --- a/gecode/iter/ranges-array.hpp +++ b/gecode/iter/ranges-array.hpp @@ -63,7 +63,7 @@ namespace Gecode { namespace Iter { namespace Ranges { /// \name Constructors and initialization //@{ /// Default constructor - Array(void); + Array(void) = default; /// Initialize with \a n ranges from \a r Array(Range* r, unsigned int n); /// Initialize with \a n ranges from \a r @@ -95,9 +95,6 @@ namespace Gecode { namespace Iter { namespace Ranges { //@} }; - forceinline - Array::Array(void) {} - forceinline Array::Array(Range* r0, unsigned int n0) : r(r0), c(0U), n(n0) {} diff --git a/gecode/iter/ranges-cache.hpp b/gecode/iter/ranges-cache.hpp index 3cf265f45a..6aabfd01d9 100644 --- a/gecode/iter/ranges-cache.hpp +++ b/gecode/iter/ranges-cache.hpp @@ -46,9 +46,9 @@ namespace Gecode { namespace Iter { namespace Ranges { /// \name Constructors and initialization //@{ /// Default constructor - Cache(void); + Cache(void) = default; /// Copy constructor - Cache(const Cache& m); + Cache(const Cache& m) = default; /// Initialize with ranges from \a i template Cache(Region& r, I& i); @@ -60,13 +60,6 @@ namespace Gecode { namespace Iter { namespace Ranges { //@} }; - forceinline - Cache::Cache(void) {} - - forceinline - Cache::Cache(const Cache& m) - : RangeListIter(m) {} - template void Cache::init(Region& r, I& i) { diff --git a/gecode/iter/ranges-compl.hpp b/gecode/iter/ranges-compl.hpp index 4d822023b7..59f99255ec 100644 --- a/gecode/iter/ranges-compl.hpp +++ b/gecode/iter/ranges-compl.hpp @@ -56,7 +56,7 @@ namespace Gecode { namespace Iter { namespace Ranges { /// \name Constructors and initialization //@{ /// Default constructor - Compl(void); + Compl(void) = default; /// Initialize with iterator \a i Compl(I& i); /// Initialize with iterator \a i @@ -94,7 +94,7 @@ namespace Gecode { namespace Iter { namespace Ranges { /// \name Constructors and initialization //@{ /// Default constructor - ComplVal(void); + ComplVal(void) = default; /// Initialize with iterator \a i ComplVal(int umin, int umax, I& i); /// Initialize with iterator \a i @@ -129,10 +129,6 @@ namespace Gecode { namespace Iter { namespace Ranges { } } - template - forceinline - Compl::Compl(void) {} - template forceinline Compl::Compl(I& i0) @@ -181,10 +177,6 @@ namespace Gecode { namespace Iter { namespace Ranges { } } - template - forceinline - ComplVal::ComplVal(void) {} - template forceinline ComplVal::ComplVal(int umin, int umax, I& i0) diff --git a/gecode/iter/ranges-diff.hpp b/gecode/iter/ranges-diff.hpp index 59da2e784d..e63b672718 100644 --- a/gecode/iter/ranges-diff.hpp +++ b/gecode/iter/ranges-diff.hpp @@ -50,7 +50,7 @@ namespace Gecode { namespace Iter { namespace Ranges { /// \name Constructors and initialization //@{ /// Default constructor - Diff(void); + Diff(void) = default; /// Initialize with iterator \a i and \a j Diff(I& i, J& j); /// Initialize with iterator \a i and \a j @@ -104,10 +104,6 @@ namespace Gecode { namespace Iter { namespace Ranges { finish(); } - template - forceinline - Diff::Diff(void) {} - template forceinline Diff::Diff(I& i0, J& j0) diff --git a/gecode/iter/ranges-empty.hpp b/gecode/iter/ranges-empty.hpp index 9e1ac4b278..e2d71a225d 100644 --- a/gecode/iter/ranges-empty.hpp +++ b/gecode/iter/ranges-empty.hpp @@ -43,7 +43,7 @@ namespace Gecode { namespace Iter { namespace Ranges { /// \name Constructors and initialization //@{ /// Default constructor - Empty(void); + Empty(void) = default; /// Initialize void init(void); //@} @@ -67,9 +67,6 @@ namespace Gecode { namespace Iter { namespace Ranges { //@} }; - forceinline - Empty::Empty(void) {} - forceinline void Empty::init(void) {} diff --git a/gecode/iter/ranges-inter.hpp b/gecode/iter/ranges-inter.hpp index 26eb01e549..6df6f0a61b 100644 --- a/gecode/iter/ranges-inter.hpp +++ b/gecode/iter/ranges-inter.hpp @@ -51,7 +51,7 @@ namespace Gecode { namespace Iter { namespace Ranges { /// \name Constructors and initialization //@{ /// Default constructor - Inter(void); + Inter(void) = default; /// Initialize with iterator \a i and \a j Inter(I& i, J& j); /// Initialize with iterator \a i and \a j @@ -79,7 +79,7 @@ namespace Gecode { namespace Iter { namespace Ranges { /// \name Constructors and initialization //@{ /// Default constructor - NaryInter(void); + NaryInter(void) = default; /// Initialize with single iterator \a i template NaryInter(Region& r, I& i); @@ -140,10 +140,6 @@ namespace Gecode { namespace Iter { namespace Ranges { finish(); } - template - forceinline - Inter::Inter(void) {} - template forceinline Inter::Inter(I& i0, J& j0) @@ -164,9 +160,6 @@ namespace Gecode { namespace Iter { namespace Ranges { * */ - forceinline - NaryInter::NaryInter(void) {} - template forceinline void NaryInter::init(Region& r, I& i) { diff --git a/gecode/iter/ranges-map.hpp b/gecode/iter/ranges-map.hpp index de84ed826c..501f891078 100644 --- a/gecode/iter/ranges-map.hpp +++ b/gecode/iter/ranges-map.hpp @@ -91,7 +91,7 @@ namespace Gecode { namespace Iter { namespace Ranges { /// \name Constructors and initialization //@{ /// Default constructor - Map(void); + Map(void) = default; /// Initialize with ranges from \a i Map(I& i); /// Initialize with ranges from \a i and map \a m @@ -122,7 +122,7 @@ namespace Gecode { namespace Iter { namespace Ranges { /// \name Constructors and initialization //@{ /// Default constructor - Map(void); + Map(void) = default; /// Initialize with ranges from \a i Map(I& i); /// Initialize with ranges from \a i and map \a m @@ -152,10 +152,6 @@ namespace Gecode { namespace Iter { namespace Ranges { //@} }; - template - forceinline - Map::Map(void) {} - template forceinline void Map::next(void) { @@ -205,10 +201,6 @@ namespace Gecode { namespace Iter { namespace Ranges { next(); } - template - forceinline - Map::Map(void) {} - template forceinline void Map::init(I& i0) { diff --git a/gecode/iter/ranges-minmax.hpp b/gecode/iter/ranges-minmax.hpp index ef4d7eddd0..95c47dc751 100644 --- a/gecode/iter/ranges-minmax.hpp +++ b/gecode/iter/ranges-minmax.hpp @@ -56,7 +56,7 @@ namespace Gecode { namespace Iter { namespace Ranges { /// \name Constructors and initialization //@{ /// Default constructor - MinMax(void); + MinMax(void) = default; /// Initialize with range \a min to \a max MinMax(int min, int max); //@} @@ -84,9 +84,6 @@ namespace Gecode { namespace Iter { namespace Ranges { ma = 0; } - forceinline - MinMax::MinMax(void) {} - forceinline MinMax::MinMax(int min, int max) : mi(min), ma(max) {} diff --git a/gecode/iter/ranges-minus.hpp b/gecode/iter/ranges-minus.hpp index 45c7aaedd1..e7d5285b99 100644 --- a/gecode/iter/ranges-minus.hpp +++ b/gecode/iter/ranges-minus.hpp @@ -48,9 +48,9 @@ namespace Gecode { namespace Iter { namespace Ranges { /// \name Constructors and initialization //@{ /// Default constructor - Minus(void); + Minus(void) = default; /// Copy constructor - Minus(const Minus& m); + Minus(const Minus& m) = default; /// Initialize with ranges from \a i template Minus(Region& r, I& i); @@ -62,13 +62,6 @@ namespace Gecode { namespace Iter { namespace Ranges { //@} }; - forceinline - Minus::Minus(void) {} - - forceinline - Minus::Minus(const Minus& m) - : RangeListIter(m) {} - template void Minus::init(Region& r, I& i) { diff --git a/gecode/iter/ranges-negative.hpp b/gecode/iter/ranges-negative.hpp index 3b39ba814e..f0c71ddcc9 100644 --- a/gecode/iter/ranges-negative.hpp +++ b/gecode/iter/ranges-negative.hpp @@ -52,7 +52,7 @@ namespace Gecode { namespace Iter { namespace Ranges { /// \name Constructors and initialization //@{ /// Default constructor - Negative(void); + Negative(void) = default; /// Initialize with ranges from \a i Negative(I& i); /// Initialize with ranges from \a i @@ -78,10 +78,6 @@ namespace Gecode { namespace Iter { namespace Ranges { //@} }; - template - forceinline - Negative::Negative(void) {} - template forceinline void Negative::init(I& i0) { diff --git a/gecode/iter/ranges-offset.hpp b/gecode/iter/ranges-offset.hpp index 31d09a5c89..95e39291a4 100644 --- a/gecode/iter/ranges-offset.hpp +++ b/gecode/iter/ranges-offset.hpp @@ -49,7 +49,7 @@ namespace Gecode { namespace Iter { namespace Ranges { /// \name Constructors and initialization //@{ /// Default constructor - Offset(void); + Offset(void) = default; /// Initialize with ranges from \a i and offset \a c Offset(I& i, int c); /// Initialize with ranges from \a i and offset \a c @@ -75,10 +75,6 @@ namespace Gecode { namespace Iter { namespace Ranges { //@} }; - template - forceinline - Offset::Offset(void) {} - template inline void Offset::init(I& i0, int c0) { diff --git a/gecode/iter/ranges-positive.hpp b/gecode/iter/ranges-positive.hpp index 84e0e9a852..bec045f400 100644 --- a/gecode/iter/ranges-positive.hpp +++ b/gecode/iter/ranges-positive.hpp @@ -51,7 +51,7 @@ namespace Gecode { namespace Iter { namespace Ranges { /// \name Constructors and initialization //@{ /// Default constructor - Positive(void); + Positive(void) = default; /// Initialize with ranges from \a i Positive(I& i); /// Initialize with ranges from \a i @@ -77,10 +77,6 @@ namespace Gecode { namespace Iter { namespace Ranges { //@} }; - template - forceinline - Positive::Positive(void) {} - template forceinline void Positive::init(I& i0) { diff --git a/gecode/iter/ranges-rangelist.hpp b/gecode/iter/ranges-rangelist.hpp index fa794dc48f..6616ec3e21 100644 --- a/gecode/iter/ranges-rangelist.hpp +++ b/gecode/iter/ranges-rangelist.hpp @@ -49,7 +49,7 @@ namespace Gecode { namespace Iter { namespace Ranges { /// \name Constructors and initialization //@{ /// Default constructor - RangeList(void); + RangeList(void) = default; /// Initialize with range list \a s RangeList(const Gecode::RangeList* s); /// Initialize with range list \a s @@ -75,9 +75,6 @@ namespace Gecode { namespace Iter { namespace Ranges { //@} }; - forceinline - RangeList::RangeList(void) {} - forceinline RangeList::RangeList(const Gecode::RangeList* s) : c(s) {} diff --git a/gecode/iter/ranges-scale.hpp b/gecode/iter/ranges-scale.hpp index b1ec3244c6..05c538cc6f 100644 --- a/gecode/iter/ranges-scale.hpp +++ b/gecode/iter/ranges-scale.hpp @@ -60,7 +60,7 @@ namespace Gecode { namespace Iter { namespace Ranges { /// \name Constructors and initialization //@{ /// Default constructor - ScaleUp(void); + ScaleUp(void) = default; /// Initialize with ranges from \a i and scale factor \a a ScaleUp(I& i, int a); /// Initialize with ranges from \a i and scale factor \a a @@ -103,7 +103,7 @@ namespace Gecode { namespace Iter { namespace Ranges { /// \name Constructors and initialization //@{ /// Default constructor - ScaleDown(void); + ScaleDown(void) = default; /// Initialize with ranges from \a i and scale factor \a a ScaleDown(I& i, int a); /// Initialize with ranges from \a i and scale factor \a a @@ -117,10 +117,6 @@ namespace Gecode { namespace Iter { namespace Ranges { //@} }; - template - forceinline - ScaleUp::ScaleUp(void) {} - template inline void ScaleUp::init(I& i0, int a0) { @@ -205,10 +201,6 @@ namespace Gecode { namespace Iter { namespace Ranges { } } - template - forceinline - ScaleDown::ScaleDown(void) {} - template inline void ScaleDown::init(I& i0, int a0) { diff --git a/gecode/iter/ranges-singleton-append.hpp b/gecode/iter/ranges-singleton-append.hpp index 4641bd5d05..935a163cf7 100644 --- a/gecode/iter/ranges-singleton-append.hpp +++ b/gecode/iter/ranges-singleton-append.hpp @@ -52,7 +52,7 @@ namespace Gecode { namespace Iter { namespace Ranges { /// \name Constructors and initialization //@{ /// Default constructor - SingletonAppend(void); + SingletonAppend(void) = default; /// Initialize with singleton (\a i0, \a i1) and iterator \a j SingletonAppend(int i0, int i1, J& j); /// Initialize with singleton (\a i0, \a i1) and iterator \a j @@ -83,10 +83,6 @@ namespace Gecode { namespace Iter { namespace Ranges { } } - template - forceinline - SingletonAppend::SingletonAppend(void) {} - template forceinline SingletonAppend::SingletonAppend(int i0, int i1, J& j0) diff --git a/gecode/iter/ranges-singleton.hpp b/gecode/iter/ranges-singleton.hpp index 819ee32240..09bf57b7e0 100644 --- a/gecode/iter/ranges-singleton.hpp +++ b/gecode/iter/ranges-singleton.hpp @@ -43,7 +43,7 @@ namespace Gecode { namespace Iter { namespace Ranges { /// \name Constructors and initialization //@{ /// Default constructor - Singleton(void); + Singleton(void) = default; /// Initialize with range \a min to \a max Singleton(int min, int max); /// Initialize with range \a min to \a max @@ -57,9 +57,6 @@ namespace Gecode { namespace Iter { namespace Ranges { //@} }; - forceinline - Singleton::Singleton(void) {} - forceinline Singleton::Singleton(int min, int max) : MinMax(min, max) {} diff --git a/gecode/iter/ranges-union.hpp b/gecode/iter/ranges-union.hpp index a377dbbbeb..25b34424a8 100644 --- a/gecode/iter/ranges-union.hpp +++ b/gecode/iter/ranges-union.hpp @@ -51,7 +51,7 @@ namespace Gecode { namespace Iter { namespace Ranges { /// \name Constructors and initialization //@{ /// Default constructor - Union(void); + Union(void) = default; /// Initialize with iterator \a i and \a j Union(I& i, J& j); /// Initialize with iterator \a i and \a j @@ -161,10 +161,6 @@ namespace Gecode { namespace Iter { namespace Ranges { } } - template - forceinline - Union::Union(void) {} - template forceinline Union::Union(I& i0, J& j0) diff --git a/gecode/iter/ranges-values.hpp b/gecode/iter/ranges-values.hpp index 661d34d3c6..959569b713 100644 --- a/gecode/iter/ranges-values.hpp +++ b/gecode/iter/ranges-values.hpp @@ -53,7 +53,7 @@ namespace Gecode { namespace Iter { namespace Ranges { /// \name Constructors and initialization //@{ /// Default constructor - ToValues(void); + ToValues(void) = default; /// Initialize with values from range iterator \a i ToValues(I& i); /// Initialize with values from range iterator \a i @@ -75,10 +75,6 @@ namespace Gecode { namespace Iter { namespace Ranges { //@} }; - template - forceinline - ToValues::ToValues(void) {} - template forceinline void ToValues::start(void) { diff --git a/gecode/iter/values-array.hpp b/gecode/iter/values-array.hpp index 630738e702..598bc13729 100644 --- a/gecode/iter/values-array.hpp +++ b/gecode/iter/values-array.hpp @@ -55,7 +55,7 @@ namespace Gecode { namespace Iter { namespace Values { /// \name Constructors and initialization //@{ /// Default constructor - Array(void); + Array(void) = default; /// Initialize with \a n values from \a v Array(int* v, unsigned int n); /// Initialize with \a n values from \a v @@ -83,9 +83,6 @@ namespace Gecode { namespace Iter { namespace Values { //@} }; - forceinline - Array::Array(void) {} - forceinline Array::Array(int* v0, unsigned int n0) : v(v0), c(0U), n(n0) {} diff --git a/gecode/iter/values-inter.hpp b/gecode/iter/values-inter.hpp index aca5b7abaf..a79e79868a 100644 --- a/gecode/iter/values-inter.hpp +++ b/gecode/iter/values-inter.hpp @@ -52,7 +52,7 @@ namespace Gecode { namespace Iter { namespace Values { /// \name Constructors and initialization //@{ /// Default constructor - Inter(void); + Inter(void) = default; /// Initialize with values from \a i and \a j Inter(I& i, J& j); /// Initialize with values from \a i and \a j @@ -74,10 +74,6 @@ namespace Gecode { namespace Iter { namespace Values { //@} }; - template - forceinline - Inter::Inter(void) {} - template forceinline void Inter::next(void) { diff --git a/gecode/iter/values-map.hpp b/gecode/iter/values-map.hpp index e004c7221d..171bdda361 100644 --- a/gecode/iter/values-map.hpp +++ b/gecode/iter/values-map.hpp @@ -52,7 +52,7 @@ namespace Gecode { namespace Iter { namespace Values { /// \name Constructors and initialization //@{ /// Default constructor - Map(void); + Map(void) = default; /// Initialize with values from \a i Map(I& i); /// Initialize with values from \a i and map \a m @@ -78,10 +78,6 @@ namespace Gecode { namespace Iter { namespace Values { //@} }; - template - forceinline - Map::Map(void) {} - template forceinline Map::Map(I& i0) diff --git a/gecode/iter/values-minus.hpp b/gecode/iter/values-minus.hpp index 04bdde88d5..aa8e249789 100644 --- a/gecode/iter/values-minus.hpp +++ b/gecode/iter/values-minus.hpp @@ -48,9 +48,9 @@ namespace Gecode { namespace Iter { namespace Values { /// \name Constructors and initialization //@{ /// Default constructor - Minus(void); + Minus(void) = default; /// Copy constructor - Minus(const Minus& m); + Minus(const Minus& m) = default; /// Initialize with values from \a i template Minus(Region& r, I& i); @@ -62,13 +62,6 @@ namespace Gecode { namespace Iter { namespace Values { //@} }; - forceinline - Minus::Minus(void) {} - - forceinline - Minus::Minus(const Minus& m) - : ValueListIter(m) {} - template void Minus::init(Region& r, I& i) { diff --git a/gecode/iter/values-negative.hpp b/gecode/iter/values-negative.hpp index adf451570c..aa92089744 100644 --- a/gecode/iter/values-negative.hpp +++ b/gecode/iter/values-negative.hpp @@ -48,7 +48,7 @@ namespace Gecode { namespace Iter { namespace Values { /// \name Constructors and initialization //@{ /// Default constructor - Negative(void); + Negative(void) = default; /// Initialize with values from \a i Negative(I& i); /// Initialize with values from \a i @@ -70,10 +70,6 @@ namespace Gecode { namespace Iter { namespace Values { //@} }; - template - forceinline - Negative::Negative(void) {} - template forceinline void Negative::init(I& i0) { diff --git a/gecode/iter/values-offset.hpp b/gecode/iter/values-offset.hpp index 0df00a8412..a685bf89f7 100644 --- a/gecode/iter/values-offset.hpp +++ b/gecode/iter/values-offset.hpp @@ -49,7 +49,7 @@ namespace Gecode { namespace Iter { namespace Values { /// \name Constructors and initialization //@{ /// Default constructor - Offset(void); + Offset(void) = default; /// Initialize with values from \a i and offset \a c Offset(I& i, int c); /// Initialize with values from \a i and offset \a c @@ -71,10 +71,6 @@ namespace Gecode { namespace Iter { namespace Values { //@} }; - template - forceinline - Offset::Offset(void) {} - template forceinline void Offset::init(I& i0, int c0) { diff --git a/gecode/iter/values-positive.hpp b/gecode/iter/values-positive.hpp index c7379be088..69c2025b35 100644 --- a/gecode/iter/values-positive.hpp +++ b/gecode/iter/values-positive.hpp @@ -48,7 +48,7 @@ namespace Gecode { namespace Iter { namespace Values { /// \name Constructors and initialization //@{ /// Default constructor - Positive(void); + Positive(void) = default; /// Initialize with values from \a i Positive(I& i); /// Initialize with values from \a i @@ -70,10 +70,6 @@ namespace Gecode { namespace Iter { namespace Values { //@} }; - template - forceinline - Positive::Positive(void) {} - template forceinline void Positive::init(I& i0) { diff --git a/gecode/iter/values-ranges.hpp b/gecode/iter/values-ranges.hpp index 0587af45bb..e192c9c4d5 100644 --- a/gecode/iter/values-ranges.hpp +++ b/gecode/iter/values-ranges.hpp @@ -51,7 +51,7 @@ namespace Gecode { namespace Iter { namespace Values { /// \name Constructors and initialization //@{ /// Default constructor - ToRanges(void); + ToRanges(void) = default; /// Initialize with value iterator \a i ToRanges(I& i); /// Initialize with value iterator \a i @@ -65,10 +65,6 @@ namespace Gecode { namespace Iter { namespace Values { //@} }; - template - forceinline - ToRanges::ToRanges(void) {} - template forceinline void ToRanges::operator++(void) { diff --git a/gecode/iter/values-singleton.hpp b/gecode/iter/values-singleton.hpp index 5916d3a5b6..49ca634243 100644 --- a/gecode/iter/values-singleton.hpp +++ b/gecode/iter/values-singleton.hpp @@ -49,7 +49,7 @@ namespace Gecode { namespace Iter { namespace Values { /// \name Constructors and initialization //@{ /// Default constructor - Singleton(void); + Singleton(void) = default; /// Initialize with value \a v Singleton(int v); /// Initialize with value \a v @@ -71,9 +71,6 @@ namespace Gecode { namespace Iter { namespace Values { //@} }; - forceinline - Singleton::Singleton(void) {} - forceinline Singleton::Singleton(int v0) : done(false), v(v0) {} diff --git a/gecode/iter/values-unique.hpp b/gecode/iter/values-unique.hpp index e27b577ab6..87d6e276c0 100644 --- a/gecode/iter/values-unique.hpp +++ b/gecode/iter/values-unique.hpp @@ -51,7 +51,7 @@ namespace Gecode { namespace Iter { namespace Values { /// \name Constructors and initialization //@{ /// Default constructor - Unique(void); + Unique(void) = default; /// Initialize with value iterator \a i Unique(I& i); /// Initialize with value iterator \a i @@ -73,10 +73,6 @@ namespace Gecode { namespace Iter { namespace Values { //@} }; - template - forceinline - Unique::Unique(void) {} - template forceinline Unique::Unique(I& i0) diff --git a/gecode/kernel/branch/action.cpp b/gecode/kernel/branch/action.cpp index bfff8a1168..5f8ef7bdfb 100644 --- a/gecode/kernel/branch/action.cpp +++ b/gecode/kernel/branch/action.cpp @@ -43,16 +43,12 @@ namespace Gecode { const Action Action::def; - Action::Action(const Action& a) : SharedHandle(a) {} - Action& Action::operator=(const Action& a) { (void)SharedHandle::operator=(a); return *this; } - Action::~Action(void) {} - void Action::decay(Space&, double d) { if ((d < 0.0) || (d > 1.0)) diff --git a/gecode/kernel/branch/action.hpp b/gecode/kernel/branch/action.hpp index e711f83d51..b1977b15ce 100644 --- a/gecode/kernel/branch/action.hpp +++ b/gecode/kernel/branch/action.hpp @@ -84,10 +84,10 @@ namespace Gecode { * yet initialized action storage is init and the assignment operator. * */ - Action(void); + Action(void) = default; /// Copy constructor GECODE_KERNEL_EXPORT - Action(const Action& a); + Action(const Action& a) = default; /// Assignment operator GECODE_KERNEL_EXPORT Action& operator=(const Action& a); @@ -115,7 +115,7 @@ namespace Gecode { /// Destructor GECODE_KERNEL_EXPORT - ~Action(void); + ~Action(void) = default; /// \name Information access //@{ @@ -333,9 +333,6 @@ namespace Gecode { object().m.release(); } - forceinline - Action::Action(void) {} - template forceinline Action::Action(Home home, ViewArray& x, double d, bool p, bool f, diff --git a/gecode/kernel/branch/chb.cpp b/gecode/kernel/branch/chb.cpp index 2d146ffc8a..428e65a8d7 100644 --- a/gecode/kernel/branch/chb.cpp +++ b/gecode/kernel/branch/chb.cpp @@ -43,16 +43,12 @@ namespace Gecode { const CHB CHB::def; - CHB::CHB(const CHB& c) : SharedHandle(c) {} - CHB& CHB::operator=(const CHB& c) { (void)SharedHandle::operator=(c); return *this; } - CHB::~CHB(void) {} - } // namespace Gecode // STATISTICS: kernel-branch diff --git a/gecode/kernel/branch/chb.hpp b/gecode/kernel/branch/chb.hpp index c406ec731a..0a86a4bfb9 100644 --- a/gecode/kernel/branch/chb.hpp +++ b/gecode/kernel/branch/chb.hpp @@ -103,10 +103,10 @@ namespace Gecode { * yet initialized chb storage is init and the assignment operator. * */ - CHB(void); + CHB(void) = default; /// Copy constructor GECODE_KERNEL_EXPORT - CHB(const CHB& a); + CHB(const CHB& a) = default; /// Assignment operator GECODE_KERNEL_EXPORT CHB& operator=(const CHB& a); @@ -130,7 +130,7 @@ namespace Gecode { /// Destructor GECODE_KERNEL_EXPORT - ~CHB(void); + ~CHB(void) = default; /// \name Information access //@{ @@ -337,9 +337,6 @@ namespace Gecode { object().update(i, failed); } - forceinline - CHB::CHB(void) {} - template forceinline CHB::CHB(Home home, ViewArray& x, const typename BranchTraits::Merit& bm) { diff --git a/gecode/kernel/branch/filter.hpp b/gecode/kernel/branch/filter.hpp index b9e7585cb1..9cd42ebf3d 100644 --- a/gecode/kernel/branch/filter.hpp +++ b/gecode/kernel/branch/filter.hpp @@ -142,6 +142,7 @@ namespace Gecode { template forceinline + // NOLINTNEXTLINE(modernize-use-equals-default) BrancherNoFilter::BrancherNoFilter(BrancherNoFilter&) {} template diff --git a/gecode/kernel/branch/print.hpp b/gecode/kernel/branch/print.hpp index fc1b47356d..9a3c2bcf25 100644 --- a/gecode/kernel/branch/print.hpp +++ b/gecode/kernel/branch/print.hpp @@ -146,6 +146,7 @@ namespace Gecode { template forceinline + // NOLINTNEXTLINE(modernize-use-equals-default) BrancherNoPrint::BrancherNoPrint(BrancherNoPrint&) {} template diff --git a/gecode/kernel/branch/val-sel-commit.hpp b/gecode/kernel/branch/val-sel-commit.hpp index 07edeeae7a..1e9bff968c 100644 --- a/gecode/kernel/branch/val-sel-commit.hpp +++ b/gecode/kernel/branch/val-sel-commit.hpp @@ -144,7 +144,7 @@ namespace Gecode { forceinline ValSelCommitBase::ValSelCommitBase(Space&, ValSelCommitBase&) {} template - ValSelCommitBase::~ValSelCommitBase(void) {} + ValSelCommitBase::~ValSelCommitBase(void) = default; template forceinline void diff --git a/gecode/kernel/branch/view-sel.hpp b/gecode/kernel/branch/view-sel.hpp index fd6ca2fea6..470e5cde2e 100644 --- a/gecode/kernel/branch/view-sel.hpp +++ b/gecode/kernel/branch/view-sel.hpp @@ -408,7 +408,7 @@ namespace Gecode { void ViewSel::dispose(Space&) {} template - ViewSel::~ViewSel(void) {} + ViewSel::~ViewSel(void) = default; template forceinline void ViewSel::operator delete(void*) {} diff --git a/gecode/kernel/core.cpp b/gecode/kernel/core.cpp index 37e096f493..06b5c27bca 100644 --- a/gecode/kernel/core.cpp +++ b/gecode/kernel/core.cpp @@ -51,7 +51,7 @@ namespace Gecode { void VarImpDisposerBase::dispose(Space&, VarImpBase*) {} - VarImpDisposerBase::~VarImpDisposerBase(void) {} + VarImpDisposerBase::~VarImpDisposerBase(void) = default; /* * Actor @@ -59,7 +59,7 @@ namespace Gecode { */ Actor* Actor::sentinel; - Actor::~Actor(void) {} + Actor::~Actor(void) = default; /* * Propagator @@ -974,7 +974,7 @@ namespace Gecode { return false; } - NGL::~NGL(void) {} + NGL::~NGL(void) = default; /* * Groups diff --git a/gecode/kernel/core.hpp b/gecode/kernel/core.hpp index 79a77a4f39..a3ffc6d5bb 100644 --- a/gecode/kernel/core.hpp +++ b/gecode/kernel/core.hpp @@ -781,7 +781,7 @@ namespace Gecode { /// \name Construction //@{ /// Constructor - PropagatorGroup(void); + PropagatorGroup(void) = default; /// To augment a space argument Home operator()(Space& home); //@} @@ -848,7 +848,7 @@ namespace Gecode { /// \name Construction //@{ /// Constructor - BrancherGroup(void); + BrancherGroup(void) = default; /// To augment a space argument Home operator()(Space& home); //@} @@ -1310,7 +1310,7 @@ namespace Gecode { public: /// Default constructor - Council(void); + Council(void) = default; /// Construct advisor council Council(Space& home); /// Test whether council has advisor left @@ -1394,13 +1394,14 @@ namespace Gecode { /// No-op for exceptions static void operator delete(void* p, Space& home); //@} + /// Not used + static void* operator new(size_t s) = delete; + private: #ifndef __GNUC__ /// Not used (uses dispose instead) static void operator delete(void* p); #endif - /// Not used - static void* operator new(size_t s); }; /** @@ -2321,10 +2322,10 @@ namespace Gecode { Space& home; /// Previous setting bool previous; - NoGPI(const NoGPI&) = delete; - NoGPI& operator=(const NoGPI&) = delete; public: + NoGPI(const NoGPI&) = delete; + NoGPI& operator=(const NoGPI&) = delete; /// Suppress global information for new propagators in \a home explicit NoGPI(Space& home); /// Restore the previous setting @@ -2344,10 +2345,10 @@ namespace Gecode { Space& home; /// Previous setting bool previous; - UseGPI(const UseGPI&) = delete; - UseGPI& operator=(const UseGPI&) = delete; public: + UseGPI(const UseGPI&) = delete; + UseGPI& operator=(const UseGPI&) = delete; /// Enable global information for new propagators in \a home explicit UseGPI(Space& home); /// Restore the previous setting @@ -3507,7 +3508,7 @@ namespace Gecode { NoGoods::ng(unsigned long int n0) { n.store(n0, std::memory_order_release); } - forceinline NoGoods::~NoGoods(void) {} + forceinline NoGoods::~NoGoods(void) = default; /* * Contexts of meta search hooks @@ -4321,7 +4322,7 @@ namespace Gecode { return bid; } - forceinline Choice::~Choice(void) {} + forceinline Choice::~Choice(void) = default; /* * No-good literal @@ -4448,9 +4449,6 @@ namespace Gecode { * Advisor council * */ - template - forceinline - Council::Council(void) {} template forceinline @@ -5560,9 +5558,6 @@ namespace Gecode { return gid; } - forceinline - PropagatorGroup::PropagatorGroup(void) {} - forceinline PropagatorGroup::PropagatorGroup(unsigned int gid) : Group(gid) {} @@ -5588,9 +5583,6 @@ namespace Gecode { return *this; } - forceinline - BrancherGroup::BrancherGroup(void) {} - forceinline BrancherGroup::BrancherGroup(unsigned int gid) : Group(gid) {} diff --git a/gecode/kernel/data/array.hpp b/gecode/kernel/data/array.hpp index bafdde2961..442316c78b 100644 --- a/gecode/kernel/data/array.hpp +++ b/gecode/kernel/data/array.hpp @@ -690,7 +690,7 @@ namespace Gecode { /// \name Constructors and initialization //@{ /// Allocate empty array - ArgArray(void); + ArgArray(void) = default; /// Allocate array with \a n elements explicit ArgArray(int n); /// Allocate array with \a n elements and initialize with elements from array \a e @@ -778,7 +778,7 @@ namespace Gecode { /// \name Constructors and initialization //@{ /// Allocate empty array - VarArgArray(void); + VarArgArray(void) = default; /// Allocate array with \a n elements explicit VarArgArray(int n); /// Initialize from variable argument array \a a (copy elements) @@ -1692,10 +1692,6 @@ namespace Gecode { * */ - template - forceinline - ArgArray::ArgArray(void) {} - template forceinline ArgArray::ArgArray(int n) @@ -1771,10 +1767,6 @@ namespace Gecode { * */ - template - forceinline - VarArgArray::VarArgArray(void) {} - template forceinline VarArgArray::VarArgArray(int n) diff --git a/gecode/kernel/data/shared-array.hpp b/gecode/kernel/data/shared-array.hpp index 20974da5bd..16c4e70a74 100644 --- a/gecode/kernel/data/shared-array.hpp +++ b/gecode/kernel/data/shared-array.hpp @@ -113,7 +113,7 @@ namespace Gecode { * yet initialized shared array is init and the assignment operator . * */ - SharedArray(void); + SharedArray(void) = default; /// Initialize as array with \a n elements SharedArray(int n); /** @@ -238,10 +238,6 @@ namespace Gecode { return a + n; } - template - forceinline - SharedArray::SharedArray(void) {} - template forceinline SharedArray::SharedArray(int n) diff --git a/gecode/kernel/data/shared-data.hpp b/gecode/kernel/data/shared-data.hpp index 2f33669144..639f143813 100644 --- a/gecode/kernel/data/shared-data.hpp +++ b/gecode/kernel/data/shared-data.hpp @@ -64,7 +64,7 @@ namespace Gecode { SharedData(Data&& d) requires std::is_move_constructible_v; /// Create as uninitialized - SharedData(void); + SharedData(void) = default; /// Copy constructor SharedData(const SharedData& sd); /// Assignment operator @@ -72,7 +72,7 @@ namespace Gecode { /// Provide access to data const Data& operator()(void) const; /// Destructors - ~SharedData(void); + ~SharedData(void) = default; }; template @@ -86,7 +86,7 @@ namespace Gecode { : d(std::move(d0)) {} template - forceinline SharedData::SDO::~SDO(void) {} + forceinline SharedData::SDO::~SDO(void) = default; template forceinline @@ -99,10 +99,6 @@ namespace Gecode { requires std::is_move_constructible_v : SharedHandle(new SDO(std::move(d))) {} - template - forceinline - SharedData::SharedData(void) {} - template forceinline SharedData::SharedData(const SharedData& sd) @@ -120,9 +116,6 @@ namespace Gecode { return static_cast(object())->d; } - template - forceinline SharedData::~SharedData(void) {} - } // namespace Gecode // STATISTICS: kernel-other diff --git a/gecode/kernel/memory/allocators.hpp b/gecode/kernel/memory/allocators.hpp index d3db515b7b..489cf093f5 100644 --- a/gecode/kernel/memory/allocators.hpp +++ b/gecode/kernel/memory/allocators.hpp @@ -208,7 +208,7 @@ namespace Gecode { * \brief Copy construction * @param al The allocator to copy. */ - space_allocator(space_allocator const& al) noexcept : space(al.space) {} + space_allocator(space_allocator const& al) noexcept = default; /** * \brief Assignment operator * @param al The allocator to assign. @@ -384,7 +384,7 @@ namespace Gecode { * \brief Copy construction * @param al The allocator to copy. */ - region_allocator(region_allocator const& al) noexcept : region(al.region) {} + region_allocator(region_allocator const& al) noexcept = default; /** * \brief Copy from other instantiation. * @param al The source allocator. diff --git a/gecode/kernel/memory/manager.hpp b/gecode/kernel/memory/manager.hpp index d830665a3a..6890edc5ed 100644 --- a/gecode/kernel/memory/manager.hpp +++ b/gecode/kernel/memory/manager.hpp @@ -103,7 +103,7 @@ namespace Gecode { public: /// Use uninitialized - FreeList(void); + FreeList(void) = default; /// Initialize with next freelist object \a n FreeList(FreeList* n); /// Return next freelist object @@ -245,9 +245,6 @@ namespace Gecode { * */ - forceinline - FreeList::FreeList(void) {} - forceinline FreeList::FreeList(FreeList* n) : _next(n) {} diff --git a/gecode/kernel/range-list.hpp b/gecode/kernel/range-list.hpp index a8cddb41a2..f8f5538482 100644 --- a/gecode/kernel/range-list.hpp +++ b/gecode/kernel/range-list.hpp @@ -127,6 +127,7 @@ namespace Gecode { */ forceinline + // NOLINTNEXTLINE(modernize-use-equals-default) RangeList::RangeList(void) {} forceinline diff --git a/gecode/kernel/shared-space-data.hpp b/gecode/kernel/shared-space-data.hpp index 313043ab66..99d60cd56c 100644 --- a/gecode/kernel/shared-space-data.hpp +++ b/gecode/kernel/shared-space-data.hpp @@ -43,43 +43,34 @@ namespace Gecode { namespace Kernel { /// The global propagator information GPI gpi; /// Default constructor - Data(void); + Data(void) = default; /// Destructor ~Data(void) override; }; /// Initialize SharedSpaceData(void); /// Initialize from \a ssd - SharedSpaceData(const SharedSpaceData& ssd); + SharedSpaceData(const SharedSpaceData& ssd) = default; /// Assignment operator SharedSpaceData& operator=(const SharedSpaceData& r); /// Delete - ~SharedSpaceData(void); + ~SharedSpaceData(void) = default; /// Provide access Data& data(void) const; }; - forceinline - SharedSpaceData::Data::Data(void) {} - - forceinline SharedSpaceData::Data::~Data(void) {} + forceinline SharedSpaceData::Data::~Data(void) = default; forceinline SharedSpaceData::SharedSpaceData(void) : SharedHandle(new Data) {} - forceinline - SharedSpaceData::SharedSpaceData(const SharedSpaceData& ssd) - : SharedHandle(ssd) {} - forceinline SharedSpaceData& SharedSpaceData::operator=(const SharedSpaceData& ssd) { (void)SharedHandle::operator=(ssd); return *this; } - forceinline SharedSpaceData::~SharedSpaceData(void) {} - forceinline SharedSpaceData::Data& SharedSpaceData::data(void) const { return static_cast(*object()); diff --git a/gecode/kernel/trace/filter.cpp b/gecode/kernel/trace/filter.cpp index 7c03f95617..6e62ab015c 100644 --- a/gecode/kernel/trace/filter.cpp +++ b/gecode/kernel/trace/filter.cpp @@ -146,6 +146,7 @@ namespace Gecode { */ forceinline + // NOLINTNEXTLINE(modernize-use-equals-default) TraceFilter::TFO::StackFrame::StackFrame(void) {} forceinline TraceFilter::TFO::StackFrame::StackFrame(TFE::Node* n0, bool neg0) @@ -191,8 +192,6 @@ namespace Gecode { TraceFilter::TraceFilter(BrancherGroup g) : SharedHandle(new TFO(g)) {} - TraceFilter::TraceFilter(const TraceFilter& tf) : SharedHandle(tf) {} - TraceFilter& TraceFilter::operator=(const TraceFilter& tf) { return static_cast(SharedHandle::operator=(tf)); diff --git a/gecode/kernel/trace/filter.hpp b/gecode/kernel/trace/filter.hpp index 8febdd3d27..a44e86b8c2 100644 --- a/gecode/kernel/trace/filter.hpp +++ b/gecode/kernel/trace/filter.hpp @@ -196,7 +196,7 @@ namespace Gecode { TraceFilter(BrancherGroup g); /// Copy constructor GECODE_KERNEL_EXPORT - TraceFilter(const TraceFilter& tf); + TraceFilter(const TraceFilter& tf) = default; /// Assignment operator GECODE_KERNEL_EXPORT TraceFilter& operator=(const TraceFilter& tf); diff --git a/gecode/kernel/trace/tracer.hpp b/gecode/kernel/trace/tracer.hpp index 2c3f74d32d..b67b1602c0 100644 --- a/gecode/kernel/trace/tracer.hpp +++ b/gecode/kernel/trace/tracer.hpp @@ -90,7 +90,7 @@ namespace Gecode { public: /// Constructor - ViewTracer(void); + ViewTracer(void) = default; /** * \brief Init function * @@ -168,7 +168,7 @@ namespace Gecode { public: /// Constructor - Tracer(void); + Tracer(void) = default; /** * \brief Propagate function * @@ -235,10 +235,6 @@ namespace Gecode { * View tracer */ - template - forceinline - ViewTracer::ViewTracer(void) {} - template forceinline void ViewTracer::_init(const Space& home, const ViewTraceRecorder& t) { @@ -272,15 +268,12 @@ namespace Gecode { } template - forceinline ViewTracer::~ViewTracer(void) {} + forceinline ViewTracer::~ViewTracer(void) = default; /* * Tracer */ - forceinline - Tracer::Tracer(void) {} - forceinline void Tracer::_propagate(const Space& home, const PropagateTraceInfo& pti) { Support::Lock l(m); @@ -297,7 +290,7 @@ namespace Gecode { post(home, pti); } - forceinline Tracer::~Tracer(void) {} + forceinline Tracer::~Tracer(void) = default; } // namespace Gecode diff --git a/gecode/kernel/var-imp.hpp b/gecode/kernel/var-imp.hpp index f4390d5e5c..120731b4bd 100644 --- a/gecode/kernel/var-imp.hpp +++ b/gecode/kernel/var-imp.hpp @@ -59,7 +59,7 @@ namespace Gecode { namespace Int { public: /// Constructor for creating static instance of variable - IntVarImpBase(void); + IntVarImpBase(void) = default; /// Constructor for creating variable IntVarImpBase(Gecode::Space& home); /// \name Dependencies @@ -106,7 +106,7 @@ namespace Gecode { namespace Int { public: /// Constructor for creating static instance of variable - BoolVarImpBase(void); + BoolVarImpBase(void) = default; /// Constructor for creating variable BoolVarImpBase(Gecode::Space& home); /// \name Dependencies @@ -153,7 +153,7 @@ namespace Gecode { namespace Set { public: /// Constructor for creating static instance of variable - SetVarImpBase(void); + SetVarImpBase(void) = default; /// Constructor for creating variable SetVarImpBase(Gecode::Space& home); /// \name Dependencies @@ -200,7 +200,7 @@ namespace Gecode { namespace Float { public: /// Constructor for creating static instance of variable - FloatVarImpBase(void); + FloatVarImpBase(void) = default; /// Constructor for creating variable FloatVarImpBase(Gecode::Space& home); /// \name Dependencies @@ -240,9 +240,6 @@ namespace Gecode { namespace Float { #ifdef GECODE_HAS_INT_VARS namespace Gecode { namespace Int { - forceinline - IntVarImpBase::IntVarImpBase(void) {} - forceinline IntVarImpBase::IntVarImpBase(Gecode::Space& home) : Gecode::VarImp(home) {} @@ -303,9 +300,6 @@ namespace Gecode { namespace Int { #ifdef GECODE_HAS_INT_VARS namespace Gecode { namespace Int { - forceinline - BoolVarImpBase::BoolVarImpBase(void) {} - forceinline BoolVarImpBase::BoolVarImpBase(Gecode::Space& home) : Gecode::VarImp(home) {} @@ -347,9 +341,6 @@ namespace Gecode { namespace Int { #ifdef GECODE_HAS_SET_VARS namespace Gecode { namespace Set { - forceinline - SetVarImpBase::SetVarImpBase(void) {} - forceinline SetVarImpBase::SetVarImpBase(Gecode::Space& home) : Gecode::VarImp(home) {} @@ -441,9 +432,6 @@ namespace Gecode { namespace Set { #ifdef GECODE_HAS_FLOAT_VARS namespace Gecode { namespace Float { - forceinline - FloatVarImpBase::FloatVarImpBase(void) {} - forceinline FloatVarImpBase::FloatVarImpBase(Gecode::Space& home) : Gecode::VarImp(home) {} diff --git a/gecode/kernel/view.hpp b/gecode/kernel/view.hpp index 5b26096aeb..e6c52aaf09 100644 --- a/gecode/kernel/view.hpp +++ b/gecode/kernel/view.hpp @@ -236,7 +236,7 @@ namespace Gecode { /// View from which this view is derived View x; /// Default constructor - DerivedView(void); + DerivedView(void) = default; public: /// Initialize with view \a y @@ -569,10 +569,6 @@ namespace Gecode { * */ - template - forceinline - DerivedView::DerivedView(void) {} - template forceinline DerivedView::DerivedView(const View& y) diff --git a/gecode/minimodel.hh b/gecode/minimodel.hh index d28a0840eb..4b2721af39 100644 --- a/gecode/minimodel.hh +++ b/gecode/minimodel.hh @@ -358,7 +358,7 @@ namespace Gecode { /// Negate relation type static IntRelType neg(IntRelType irt); /// Default constructor - LinIntRel(void); + LinIntRel(void) = default; public: /// Create linear relation for expressions \a l and \a r @@ -788,7 +788,7 @@ namespace Gecode { /// Negate relation type static FloatRelType neg(FloatRelType frt); /// Default constructor - LinFloatRel(void); + LinFloatRel(void) = default; public: /// Create linear float relation for expressions \a l and \a r @@ -1057,7 +1057,7 @@ namespace Gecode { public: /// Default constructor - SetRel(void); + SetRel(void) = default; /// Constructor SetRel(const SetExpr& e0, SetRelType srt, const SetExpr& e1); /// Constructor @@ -1142,7 +1142,7 @@ namespace Gecode { class GECODE_VTABLE_EXPORT Misc : public HeapAllocated { public: /// Default constructor - Misc(void); + Misc(void) = default; /** Constrain \a b to be equivalent to the expression * (negated if \a neg) with propagation level * \a ipl. @@ -2065,7 +2065,7 @@ namespace Gecode { class GECODE_VTABLE_EXPORT IntMinimizeSpace : public Space { public: /// Default constructor - IntMinimizeSpace(void); + IntMinimizeSpace(void) = default; /// Constructor for cloning IntMinimizeSpace(IntMinimizeSpace& s); /// Member function constraining according to decreasing cost @@ -2085,7 +2085,7 @@ namespace Gecode { class GECODE_VTABLE_EXPORT IntMaximizeSpace : public Space { public: /// Default constructor - IntMaximizeSpace(void); + IntMaximizeSpace(void) = default; /// Constructor for cloning IntMaximizeSpace(IntMaximizeSpace& s); /// Member function constraining according to increasing cost @@ -2105,7 +2105,7 @@ namespace Gecode { class GECODE_VTABLE_EXPORT IntLexMinimizeSpace : public Space { public: /// Default constructor - IntLexMinimizeSpace(void); + IntLexMinimizeSpace(void) = default; /// Constructor for cloning IntLexMinimizeSpace(IntLexMinimizeSpace& s); /// Member function constraining according to decreasing costs @@ -2125,7 +2125,7 @@ namespace Gecode { class GECODE_VTABLE_EXPORT IntLexMaximizeSpace : public Space { public: /// Default constructor - IntLexMaximizeSpace(void); + IntLexMaximizeSpace(void) = default; /// Constructor for cloning IntLexMaximizeSpace(IntLexMaximizeSpace& s); /// Member function constraining according to increasing costs diff --git a/gecode/minimodel/bool-expr.cpp b/gecode/minimodel/bool-expr.cpp index 5cc28714e9..c31dfbbb01 100644 --- a/gecode/minimodel/bool-expr.cpp +++ b/gecode/minimodel/bool-expr.cpp @@ -240,7 +240,7 @@ namespace Gecode { return *this; } - BoolExpr::Misc::~Misc(void) {} + BoolExpr::Misc::~Misc(void) = default; BoolExpr::~BoolExpr(void) { if (n->decrement()) diff --git a/gecode/minimodel/bool-expr.hpp b/gecode/minimodel/bool-expr.hpp index 81811cc099..1a68e4e590 100644 --- a/gecode/minimodel/bool-expr.hpp +++ b/gecode/minimodel/bool-expr.hpp @@ -48,9 +48,6 @@ namespace Gecode { return expr(home, LinIntExpr(static_cast(value)), ipls); } - forceinline - BoolExpr::Misc::Misc(void) {} - } // namespace Gecode // STATISTICS: minimodel-any diff --git a/gecode/minimodel/float-expr.hpp b/gecode/minimodel/float-expr.hpp index 7646d65d60..59c03e9071 100644 --- a/gecode/minimodel/float-expr.hpp +++ b/gecode/minimodel/float-expr.hpp @@ -32,7 +32,7 @@ namespace Gecode { - forceinline NonLinFloatExpr::~NonLinFloatExpr(void) {} + forceinline NonLinFloatExpr::~NonLinFloatExpr(void) = default; forceinline FloatVar NonLinFloatExpr::result(Home home, FloatVar* x) { diff --git a/gecode/minimodel/float-rel.hpp b/gecode/minimodel/float-rel.hpp index cee77d802f..62e9ce51ba 100644 --- a/gecode/minimodel/float-rel.hpp +++ b/gecode/minimodel/float-rel.hpp @@ -38,8 +38,6 @@ namespace Gecode { * Operations for linear float relations * */ - forceinline - LinFloatRel::LinFloatRel(void) {} forceinline LinFloatRel::LinFloatRel(const LinFloatExpr& l, FloatRelType frt0, const LinFloatExpr& r) diff --git a/gecode/minimodel/int-expr.hpp b/gecode/minimodel/int-expr.hpp index 63972b33d4..11541a07e6 100644 --- a/gecode/minimodel/int-expr.hpp +++ b/gecode/minimodel/int-expr.hpp @@ -32,7 +32,7 @@ namespace Gecode { - forceinline NonLinIntExpr::~NonLinIntExpr(void) {} + forceinline NonLinIntExpr::~NonLinIntExpr(void) = default; forceinline IntVar NonLinIntExpr::result(Home home, IntVar* x) { diff --git a/gecode/minimodel/int-rel.hpp b/gecode/minimodel/int-rel.hpp index 9b5365cc63..0fae3197cb 100644 --- a/gecode/minimodel/int-rel.hpp +++ b/gecode/minimodel/int-rel.hpp @@ -36,8 +36,6 @@ namespace Gecode { * Operations for linear expressions * */ - forceinline - LinIntRel::LinIntRel(void) {} forceinline LinIntRel::LinIntRel(const LinIntExpr& l, IntRelType irt0, const LinIntExpr& r) diff --git a/gecode/minimodel/optimize.hpp b/gecode/minimodel/optimize.hpp index ac7523c3a5..5fdc635ddf 100644 --- a/gecode/minimodel/optimize.hpp +++ b/gecode/minimodel/optimize.hpp @@ -33,29 +33,20 @@ namespace Gecode { forceinline - IntMinimizeSpace::IntMinimizeSpace(void) {} - - forceinline + // NOLINTNEXTLINE(modernize-use-equals-default) IntMinimizeSpace::IntMinimizeSpace(IntMinimizeSpace& s) : Space(s) {} forceinline - IntMaximizeSpace::IntMaximizeSpace(void) {} - - forceinline + // NOLINTNEXTLINE(modernize-use-equals-default) IntMaximizeSpace::IntMaximizeSpace(IntMaximizeSpace& s) : Space(s) {} forceinline - IntLexMinimizeSpace::IntLexMinimizeSpace(void) {} - - forceinline + // NOLINTNEXTLINE(modernize-use-equals-default) IntLexMinimizeSpace::IntLexMinimizeSpace(IntLexMinimizeSpace& s) : Space(s) {} - forceinline - IntLexMaximizeSpace::IntLexMaximizeSpace(void) {} - forceinline IntLexMaximizeSpace::IntLexMaximizeSpace(IntLexMaximizeSpace& s) : Space(s) {} @@ -67,6 +58,7 @@ namespace Gecode { : step(s) {} forceinline + // NOLINTNEXTLINE(modernize-use-equals-default) FloatMinimizeSpace::FloatMinimizeSpace(FloatMinimizeSpace& s) : Space(s), step(s.step) {} diff --git a/gecode/minimodel/reg.cpp b/gecode/minimodel/reg.cpp index 85b2bb4f77..ef3bf8a288 100644 --- a/gecode/minimodel/reg.cpp +++ b/gecode/minimodel/reg.cpp @@ -456,7 +456,7 @@ namespace Gecode { int pos; PosSet* next; - PosSet(void); + PosSet(void) = default; PosSet(int); bool in(int) const; @@ -464,8 +464,6 @@ namespace Gecode { static PosSet* cup(PosSetAllocator&, PosSet*, PosSet*); }; - forceinline - PosSet::PosSet(void) {} forceinline PosSet::PosSet(int p) : pos(p), next(nullptr) {} diff --git a/gecode/minimodel/set-rel.hpp b/gecode/minimodel/set-rel.hpp index 12706738a7..4884a98f18 100644 --- a/gecode/minimodel/set-rel.hpp +++ b/gecode/minimodel/set-rel.hpp @@ -42,9 +42,6 @@ namespace Gecode { SetCmpRel::SetCmpRel(const SetExpr& l0, SetRelType srt0, const SetExpr& r0) : l(l0), r(r0), srt(srt0) {} - forceinline - SetRel::SetRel(void) {} - forceinline SetRel::SetRel(const SetExpr& e0, SetRelType srt, const SetExpr& e1) : _e0(e0), _srt(srt), _e1(e1) {} diff --git a/gecode/search.hh b/gecode/search.hh index 70acbeeda7..ce1b4cf11a 100644 --- a/gecode/search.hh +++ b/gecode/search.hh @@ -430,7 +430,7 @@ namespace Gecode { class GECODE_SEARCH_EXPORT GetInfo : public HeapAllocated { public: /// Initialize - GetInfo(void); + GetInfo(void) = default; /// Return info for a space virtual std::string get_info(const Space& home) const = 0; /// Delete @@ -482,7 +482,7 @@ namespace Gecode { namespace Search { /// \name Constructors and member functions //@{ /// Default constructor - Cutoff(void); + Cutoff(void) = default; /// Return the current cutoff value virtual unsigned long long int operator()(void) const = 0; /// Increment and return the next cutoff value @@ -954,7 +954,7 @@ namespace Gecode { namespace Search { /// \name Constructors and member functions //@{ /// Default constructor - Stop(void); + Stop(void) = default; /// Stop search, if returns true virtual bool stop(const Statistics& s, const Options& o) = 0; /// Destructor @@ -1185,11 +1185,11 @@ namespace Gecode { namespace Search { /// Destructor virtual ~Base(void); - private: + public: /// Disallow copy constructor - Base(const Base&); + Base(const Base&) = delete; /// Disallow assignment operator - Base& operator=(const Base&); + Base& operator=(const Base&) = delete; }; }} // namespace Gecode::Search diff --git a/gecode/search/cpprofiler/tracer.cpp b/gecode/search/cpprofiler/tracer.cpp index 076451bacf..a0c841132a 100644 --- a/gecode/search/cpprofiler/tracer.cpp +++ b/gecode/search/cpprofiler/tracer.cpp @@ -47,9 +47,7 @@ namespace Gecode { - CPProfilerSearchTracer::GetInfo::GetInfo(void) {} - - CPProfilerSearchTracer::GetInfo::~GetInfo(void) {} + CPProfilerSearchTracer::GetInfo::~GetInfo(void) = default; CPProfilerSearchTracer::CPProfilerSearchTracer(int eid, std::string name0, unsigned int port, const GetInfo* pgetinfo) diff --git a/gecode/search/cutoff.hpp b/gecode/search/cutoff.hpp index e841edd06f..964e20e5a7 100644 --- a/gecode/search/cutoff.hpp +++ b/gecode/search/cutoff.hpp @@ -36,9 +36,7 @@ namespace Gecode { namespace Search { - forceinline - Cutoff::Cutoff(void) {} - forceinline Cutoff::~Cutoff(void) {} + forceinline Cutoff::~Cutoff(void) = default; forceinline CutoffConstant::CutoffConstant(unsigned long long int c0) diff --git a/gecode/search/engine.cpp b/gecode/search/engine.cpp index f60757ec3a..96af6e2510 100644 --- a/gecode/search/engine.cpp +++ b/gecode/search/engine.cpp @@ -63,7 +63,7 @@ namespace Gecode { namespace Search { * Defined out of line so that the vtable, and with it the destructor of * the options, is only emitted in the search library. */ - Builder::~Builder(void) {} + Builder::~Builder(void) = default; }} // namespace Gecode::Search diff --git a/gecode/search/nogoods.hh b/gecode/search/nogoods.hh index 5b393c7feb..5d05390901 100644 --- a/gecode/search/nogoods.hh +++ b/gecode/search/nogoods.hh @@ -41,7 +41,7 @@ namespace Gecode { namespace Search { class GECODE_SEARCH_EXPORT NoNGL : public NGL { public: /// Constructor for creation - NoNGL(void); + NoNGL(void) = default; /// Constructor for creation NoNGL(Space& home); /// Constructor for cloning \a ngl diff --git a/gecode/search/nogoods.hpp b/gecode/search/nogoods.hpp index 0ee8a9f654..732c0cf3c1 100644 --- a/gecode/search/nogoods.hpp +++ b/gecode/search/nogoods.hpp @@ -32,9 +32,6 @@ namespace Gecode { namespace Search { - forceinline - NoNGL::NoNGL(void) {} - forceinline NoNGL::NoNGL(Space& home) : NGL(home) {} diff --git a/gecode/search/par/path.hpp b/gecode/search/par/path.hpp index fa6bbd41bf..896cb50227 100644 --- a/gecode/search/par/path.hpp +++ b/gecode/search/par/path.hpp @@ -42,6 +42,7 @@ namespace Gecode { namespace Search { namespace Par { */ template forceinline + // NOLINTNEXTLINE(modernize-use-equals-default) Path::Edge::Edge(void) {} template diff --git a/gecode/search/seq/lds.hpp b/gecode/search/seq/lds.hpp index 1cdcf037b5..dc4fe246f4 100644 --- a/gecode/search/seq/lds.hpp +++ b/gecode/search/seq/lds.hpp @@ -40,6 +40,7 @@ namespace Gecode { namespace Search { namespace Seq { template forceinline + // NOLINTNEXTLINE(modernize-use-equals-default) Probe::Node::Node(void) {} template diff --git a/gecode/search/seq/path.hpp b/gecode/search/seq/path.hpp index 1e2e41ce83..918d329372 100644 --- a/gecode/search/seq/path.hpp +++ b/gecode/search/seq/path.hpp @@ -42,6 +42,7 @@ namespace Gecode { namespace Search { namespace Seq { */ template forceinline + // NOLINTNEXTLINE(modernize-use-equals-default) Path::Edge::Edge(void) {} template diff --git a/gecode/search/stop.hpp b/gecode/search/stop.hpp index 51da3f314f..93e9dc715e 100644 --- a/gecode/search/stop.hpp +++ b/gecode/search/stop.hpp @@ -40,9 +40,7 @@ namespace Gecode { namespace Search { * Base class * */ - forceinline - Stop::Stop(void) {} - forceinline Stop::~Stop(void) {} + forceinline Stop::~Stop(void) = default; /* * Stopping for node limit diff --git a/gecode/search/trace-recorder.hpp b/gecode/search/trace-recorder.hpp index ead965e3ea..29287814da 100644 --- a/gecode/search/trace-recorder.hpp +++ b/gecode/search/trace-recorder.hpp @@ -60,7 +60,7 @@ namespace Gecode { namespace Search { public: /// Do not initialize - ID(void); + ID(void) = default; /// Initialize ID(unsigned int id); /// Access @@ -110,7 +110,7 @@ namespace Gecode { namespace Search { class ID { public: /// Do not initialize - ID(void); + ID(void) = default; /// Initialize ID(unsigned int id); /// Access @@ -156,8 +156,6 @@ namespace Gecode { namespace Search { * Simple trace recorder for a search tracer * */ - forceinline - TraceRecorder::ID::ID(void) {} forceinline TraceRecorder::ID::ID(unsigned int id) @@ -239,8 +237,6 @@ namespace Gecode { namespace Search { * Empty trace recorder * */ - forceinline - NoTraceRecorder::ID::ID(void) {} forceinline NoTraceRecorder::ID::ID(unsigned int) {} diff --git a/gecode/search/tracer.cpp b/gecode/search/tracer.cpp index 1b9fe86625..bd31c6bc6d 100644 --- a/gecode/search/tracer.cpp +++ b/gecode/search/tracer.cpp @@ -108,7 +108,7 @@ namespace Gecode { os << "trace::done()" << '\n' << std::flush; } - StdSearchTracer::~StdSearchTracer(void) {} + StdSearchTracer::~StdSearchTracer(void) = default; StdSearchTracer StdSearchTracer::def; diff --git a/gecode/search/tracer.hpp b/gecode/search/tracer.hpp index 436f24ff5e..f8d89f8be6 100644 --- a/gecode/search/tracer.hpp +++ b/gecode/search/tracer.hpp @@ -39,6 +39,7 @@ namespace Gecode { * */ forceinline + // NOLINTNEXTLINE(modernize-use-equals-default) SearchTracer::EngineInfo::EngineInfo(void) {} forceinline @@ -279,7 +280,7 @@ namespace Gecode { return w2e[wid]; } - forceinline SearchTracer::~SearchTracer(void) {} + forceinline SearchTracer::~SearchTracer(void) = default; } // namespace Gecode diff --git a/gecode/set.hh b/gecode/set.hh index 6878c9df68..224d0ad721 100644 --- a/gecode/set.hh +++ b/gecode/set.hh @@ -124,7 +124,7 @@ namespace Gecode { /// \name Constructors and initialization //@{ /// Default constructor - SetVar(void); + SetVar(void) = default; /// Initialize from set variable \a y SetVar(const SetVar& y) = default; /// Initialize from set view \a y @@ -266,7 +266,7 @@ namespace Gecode { /// \name Constructors and initialization //@{ /// Default constructor - SetVarGlbRanges(void); + SetVarGlbRanges(void) = default; /// Initialize to iterate ranges of variable \a x SetVarGlbRanges(const SetVar& x); //@} @@ -299,7 +299,7 @@ namespace Gecode { /// \name Constructors and initialization //@{ /// Default constructor - SetVarLubRanges(void); + SetVarLubRanges(void) = default; /// Initialize to iterate ranges of variable \a x SetVarLubRanges(const SetVar& x); //@} @@ -332,7 +332,7 @@ namespace Gecode { /// \name Constructors and initialization //@{ /// Default constructor - SetVarUnknownRanges(void); + SetVarUnknownRanges(void) = default; /// Initialize to iterate ranges of variable \a x SetVarUnknownRanges(const SetVar& x); //@} @@ -486,11 +486,11 @@ namespace Gecode { /// \name Constructors and initialization //@{ /// Allocate empty array - SetVarArgs(void); + SetVarArgs(void) = default; /// Allocate array with \a n elements explicit SetVarArgs(int n); /// Initialize from variable argument array \a a (copy elements) - SetVarArgs(const SetVarArgs& a); + SetVarArgs(const SetVarArgs& a) = default; /// Initialize from variable array \a a (copy elements) SetVarArgs(const VarArray& a); /// Initialize from vector \a a @@ -562,7 +562,7 @@ namespace Gecode { /// \name Creation and initialization //@{ /// Default constructor (array of size 0) - SetVarArray(void); + SetVarArray(void) = default; /// Initialize from set variable array \a a (share elements) SetVarArray(const SetVarArray&) = default; /// Initialize from set variable argument array \a a (copy elements) @@ -1044,7 +1044,7 @@ namespace Gecode { * yet initialized AFC storage is init or the assignment operator. * */ - SetAFC(void); + SetAFC(void) = default; /** * \brief Initialize for set variables \a x and decay factor \a d * @@ -1086,9 +1086,9 @@ namespace Gecode { * yet initialized action storage is init or the assignment operator. * */ - SetAction(void); + SetAction(void) = default; /// Copy constructor - SetAction(const SetAction& a); + SetAction(const SetAction& a) = default; /// Assignment operator SetAction& operator=(const SetAction& a); /** @@ -1141,9 +1141,9 @@ namespace Gecode { * yet initialized CHB storage is init or the assignment operator. * */ - SetCHB(void); + SetCHB(void) = default; /// Copy constructor - SetCHB(const SetCHB& chb); + SetCHB(const SetCHB& chb) = default; /// Assignment operator SetCHB& operator=(const SetCHB& chb); /** diff --git a/gecode/set/array.hpp b/gecode/set/array.hpp index d6297bc477..0fe8d526d4 100644 --- a/gecode/set/array.hpp +++ b/gecode/set/array.hpp @@ -43,17 +43,10 @@ namespace Gecode { * */ - forceinline - SetVarArgs::SetVarArgs(void) {} - forceinline SetVarArgs::SetVarArgs(int n) : VarArgArray(n) {} - forceinline - SetVarArgs::SetVarArgs(const SetVarArgs& a) - : VarArgArray(a) {} - forceinline SetVarArgs::SetVarArgs(const VarArray& a) : VarArgArray(a) {} @@ -71,9 +64,6 @@ namespace Gecode { SetVarArgs::SetVarArgs(InputIterator first, InputIterator last) : VarArgArray(first, last) {} - forceinline - SetVarArray::SetVarArray(void) {} - forceinline SetVarArray::SetVarArray(Space& home, const SetVarArgs& a) : VarArray(home, a) {} diff --git a/gecode/set/branch/action.hpp b/gecode/set/branch/action.hpp index 7778606bfa..6335226e9c 100644 --- a/gecode/set/branch/action.hpp +++ b/gecode/set/branch/action.hpp @@ -32,13 +32,6 @@ namespace Gecode { - forceinline - SetAction::SetAction(void) {} - - forceinline - SetAction::SetAction(const SetAction& a) - : Action(a) {} - forceinline SetAction& SetAction::operator=(const SetAction& a) { return static_cast(Action::operator=(a)); diff --git a/gecode/set/branch/afc.hpp b/gecode/set/branch/afc.hpp index 35a85e929a..01a0d29284 100644 --- a/gecode/set/branch/afc.hpp +++ b/gecode/set/branch/afc.hpp @@ -32,9 +32,6 @@ namespace Gecode { - forceinline - SetAFC::SetAFC(void) {} - forceinline SetAFC::SetAFC(Home home, const SetVarArgs& x, double d, bool share) { AFC::init(home, x, d, share); diff --git a/gecode/set/branch/chb.hpp b/gecode/set/branch/chb.hpp index 95f05115ca..bd977acc3b 100644 --- a/gecode/set/branch/chb.hpp +++ b/gecode/set/branch/chb.hpp @@ -32,13 +32,6 @@ namespace Gecode { - forceinline - SetCHB::SetCHB(void) {} - - forceinline - SetCHB::SetCHB(const SetCHB& chb) - : CHB(chb) {} - forceinline SetCHB& SetCHB::operator=(const SetCHB& chb) { return static_cast(CHB::operator=(chb)); diff --git a/gecode/set/int/weights.hpp b/gecode/set/int/weights.hpp index 724cd3de5d..d7414134dd 100644 --- a/gecode/set/int/weights.hpp +++ b/gecode/set/int/weights.hpp @@ -60,7 +60,7 @@ namespace Gecode { namespace Set { namespace Int { /// \name Constructors and initialization //@{ /// Default constructor - OverweightValues(void); + OverweightValues(void) = default; /// Initialize with elements/weights pairs, threshold \a t and iterator \a i OverweightValues(int t, SharedArray& elements0, SharedArray& weights0, I& i); /// Initialize with elements/weights pairs, threshold \a t and iterator \a i @@ -95,10 +95,6 @@ namespace Gecode { namespace Set { namespace Int { } } - template - forceinline - OverweightValues::OverweightValues(void) {} - template forceinline OverweightValues::OverweightValues(int t, SharedArray& elements0, SharedArray& weights0, I& i) diff --git a/gecode/set/rel/lq.hpp b/gecode/set/rel/lq.hpp index 012891dbcb..1bab4babd7 100644 --- a/gecode/set/rel/lq.hpp +++ b/gecode/set/rel/lq.hpp @@ -70,7 +70,7 @@ namespace Gecode { namespace Set { namespace Rel { /// Move iterator to next element void operator++(void); /// Default constructor - CSIter(void); + CSIter(void) = default; /// Constructor CSIter(CharacteristicSets& cs0, unsigned int xoff0, unsigned int yoff0); /// Test if iterator is finished @@ -135,8 +135,6 @@ namespace Gecode { namespace Set { namespace Rel { return xsize; } - forceinline - CharacteristicSets::CSIter::CSIter(void) {} forceinline CharacteristicSets::CSIter::CSIter(CharacteristicSets& cs0, unsigned int xoff0, unsigned int yoff0) : cs(&cs0), i(0), xoff(xoff0), yoff(yoff0) { diff --git a/gecode/set/trace/trace-view.hpp b/gecode/set/trace/trace-view.hpp index 9127b33e0f..93ea94c4f0 100644 --- a/gecode/set/trace/trace-view.hpp +++ b/gecode/set/trace/trace-view.hpp @@ -58,6 +58,7 @@ namespace Gecode { namespace Set { }; forceinline + // NOLINTNEXTLINE(modernize-use-equals-default) SetTraceView::SetTraceView(void) {} forceinline SetTraceView::SetTraceView(Space& home, SetView x) { diff --git a/gecode/set/var-imp.hpp b/gecode/set/var-imp.hpp index 78c03d94ee..918c41bbe9 100644 --- a/gecode/set/var-imp.hpp +++ b/gecode/set/var-imp.hpp @@ -189,7 +189,7 @@ namespace Gecode { namespace Set { /// \name Constructors and initialization //@{ /// Default constructor - BndSetRanges(void); + BndSetRanges(void) = default; /// Initialize with BndSet \a s BndSetRanges(const BndSet& s); /// Initialize with BndSet \a s @@ -213,7 +213,7 @@ namespace Gecode { namespace Set { /// \name Constructors and initialization //@{ /// Default constructor. Creates an empty set. - GLBndSet(void); + GLBndSet(void) = default; /// Default constructor. Creates an empty set. GLBndSet(Space&); /// Initialize as the set \f$ \{i,\dots,j\}\f$ @@ -232,9 +232,9 @@ namespace Gecode { namespace Set { template bool include_i(Space& home, I& i); //@} - private: - GLBndSet(const GLBndSet&); - const GLBndSet& operator=(const GLBndSet&); + public: + GLBndSet(const GLBndSet&) = delete; + const GLBndSet& operator=(const GLBndSet&) = delete; }; /** @@ -253,7 +253,7 @@ namespace Gecode { namespace Set { /// \name Constructors and initialization //@{ /// Default constructor. Creates an empty set. - LUBndSet(void); + LUBndSet(void) = default; /// Initialize as the full set including everything between Limits::min and Limits::max LUBndSet(Space& home); /// Initialize as the set \f$ \{i,\dots,j\}\f$ @@ -279,9 +279,9 @@ namespace Gecode { namespace Set { /// Exclude all elements from this set void exclude_all(Space& home); //@} - private: - LUBndSet(const LUBndSet&); - const LUBndSet& operator=(const LUBndSet&); + public: + LUBndSet(const LUBndSet&) = delete; + const LUBndSet& operator=(const LUBndSet&) = delete; }; /* @@ -300,7 +300,7 @@ namespace Gecode { namespace Set { /// \name Constructors and initialization //@{ /// Default constructor - RangesCompl(void); + RangesCompl(void) = default; /// Initialize with iterator \a i RangesCompl(I& i); /// Initialize with iterator \a i @@ -415,7 +415,7 @@ namespace Gecode { namespace Set { /// \name Constructors and initialization //@{ /// Default constructor - UnknownRanges(void); + UnknownRanges(void) = default; /// Initialize with unknown set ranges for set variable \a x UnknownRanges(const T& x); /// Initialize with unknown set ranges for set variable \a x diff --git a/gecode/set/var-imp/integerset.hpp b/gecode/set/var-imp/integerset.hpp index 0082c7e13d..dc56ccc57a 100644 --- a/gecode/set/var-imp/integerset.hpp +++ b/gecode/set/var-imp/integerset.hpp @@ -242,9 +242,6 @@ namespace Gecode { namespace Set { * */ - forceinline - BndSetRanges::BndSetRanges(void) {} - forceinline BndSetRanges::BndSetRanges(const BndSet& s) : Iter::Ranges::RangeList(s.ranges()) {} @@ -259,9 +256,6 @@ namespace Gecode { namespace Set { * */ - forceinline - GLBndSet::GLBndSet(void) {} - forceinline GLBndSet::GLBndSet(Space&) {} @@ -315,9 +309,6 @@ namespace Gecode { namespace Set { * */ - forceinline - LUBndSet::LUBndSet(void) {} - forceinline LUBndSet::LUBndSet(Space& home) : BndSet(home, Limits::min, Limits::max) {} @@ -423,8 +414,6 @@ namespace Gecode { namespace Set { * A complement iterator spezialized for the BndSet limits * */ - template - RangesCompl::RangesCompl(void) {} template RangesCompl::RangesCompl(I& i) : Iter::Ranges::Compl(i) {} diff --git a/gecode/set/var-imp/iter.hpp b/gecode/set/var-imp/iter.hpp index f8aa384183..ac9ebc2db0 100644 --- a/gecode/set/var-imp/iter.hpp +++ b/gecode/set/var-imp/iter.hpp @@ -34,10 +34,6 @@ namespace Gecode { namespace Set { - template - forceinline - UnknownRanges::UnknownRanges(void) {} - template forceinline UnknownRanges::UnknownRanges(const T& v) diff --git a/gecode/set/var-imp/set.hpp b/gecode/set/var-imp/set.hpp index 8cb11481a1..aa3fd6c11d 100644 --- a/gecode/set/var-imp/set.hpp +++ b/gecode/set/var-imp/set.hpp @@ -458,7 +458,7 @@ namespace Gecode { namespace Set { /// \name Constructors and initialization //@{ /// Default constructor - LubRanges(void); + LubRanges(void) = default; /// Initialize with ranges for variable implementation \a x LubRanges(const SetVarImp*); /// Initialize with ranges for variable implementation \a x @@ -466,9 +466,6 @@ namespace Gecode { namespace Set { //@} }; - forceinline - LubRanges::LubRanges(void) {} - forceinline LubRanges::LubRanges(const SetVarImp* x) : BndSetRanges(x->lub) {} @@ -492,7 +489,7 @@ namespace Gecode { namespace Set { /// \name Constructors and initialization //@{ /// Default constructor - GlbRanges(void); + GlbRanges(void) = default; /// Initialize with ranges for variable implementation \a x GlbRanges(const SetVarImp* x); /// Initialize with ranges for variable implementation \a x @@ -500,9 +497,6 @@ namespace Gecode { namespace Set { //@} }; - forceinline - GlbRanges::GlbRanges(void) {} - forceinline GlbRanges::GlbRanges(const SetVarImp* x) : BndSetRanges(x->glb) {} diff --git a/gecode/set/var/set.hpp b/gecode/set/var/set.hpp index df750b235d..44c0e5659a 100644 --- a/gecode/set/var/set.hpp +++ b/gecode/set/var/set.hpp @@ -41,9 +41,6 @@ namespace Gecode { * */ - forceinline - SetVar::SetVar(void) {} - forceinline SetVar::SetVar(const Set::SetView& y) : VarImpVar(y.varimp()) {} @@ -113,9 +110,6 @@ namespace Gecode { * */ - forceinline - SetVarGlbRanges::SetVarGlbRanges(void) {} - forceinline SetVarGlbRanges::SetVarGlbRanges(const SetVar& s) : iter(s.varimp()) {} @@ -145,9 +139,6 @@ namespace Gecode { return iter.width(); } - forceinline - SetVarLubRanges::SetVarLubRanges(void) {} - forceinline SetVarLubRanges::SetVarLubRanges(const SetVar& s) : iter(s.varimp()) {} @@ -177,9 +168,6 @@ namespace Gecode { return iter.width(); } - forceinline - SetVarUnknownRanges::SetVarUnknownRanges(void) {} - forceinline SetVarUnknownRanges::SetVarUnknownRanges(const SetVar& s) { iter.init(s.varimp()); diff --git a/gecode/set/view.hpp b/gecode/set/view.hpp index 31b7faaeba..b4a246d3bf 100644 --- a/gecode/set/view.hpp +++ b/gecode/set/view.hpp @@ -60,7 +60,7 @@ namespace Gecode { namespace Set { /// \name Constructors and initialization //@{ /// Default constructor - SetView(void); + SetView(void) = default; /// Initialize from set variable \a y SetView(const SetVar& y); /// Initialize from set variable implementation \a y @@ -337,7 +337,7 @@ namespace Gecode { namespace Set { /// \name Constructors and initialization //@{ /// Default constructor - EmptyView(void); + EmptyView(void) = default; //@} /// \name Value access @@ -463,7 +463,7 @@ namespace Gecode { namespace Set { /// \name Constructors and initialization //@{ /// Default constructor - UniverseView(void); + UniverseView(void) = default; //@} /// \name Value access @@ -600,7 +600,7 @@ namespace Gecode { namespace Set { /// \name Constructors and initialization //@{ /// Default constructor - SingletonView(void); + SingletonView(void) = default; /// Initialize with integer view \a y SingletonView(Gecode::Int::IntView& y); /// Initialize with integer variable \a y @@ -773,7 +773,7 @@ namespace Gecode { namespace Set { /// \name Constructors and initialization //@{ /// Default constructor - ComplementView(void); + ComplementView(void) = default; /// Initialize with set view \a y explicit ComplementView(View& y); //@} @@ -954,7 +954,7 @@ namespace Gecode { namespace Set { /// \name Constructors and initialization //@{ /// Default constructor - CachedView(void); + CachedView(void) = default; /// Initialize with set view \a y explicit CachedView(const View& y); //@} diff --git a/gecode/set/view/cached.hpp b/gecode/set/view/cached.hpp index 2b04c96998..4af0b822e3 100644 --- a/gecode/set/view/cached.hpp +++ b/gecode/set/view/cached.hpp @@ -34,10 +34,6 @@ namespace Gecode { namespace Set { - template - forceinline - CachedView::CachedView(void) {} - template forceinline CachedView::CachedView(const View& y) @@ -325,7 +321,7 @@ namespace Gecode { namespace Set { /// \name Constructors and initialization //@{ /// Default constructor - LubRanges(void) {} + LubRanges(void) = default; /// Initialize with ranges for view \a x LubRanges(const CachedView& x); /// Initialize with ranges for view \a x @@ -354,7 +350,7 @@ namespace Gecode { namespace Set { /// \name Constructors and initialization //@{ /// Default constructor - GlbRanges(void) {} + GlbRanges(void) = default; /// Initialize with ranges for view \a x GlbRanges(const CachedView& x); /// Initialize with ranges for view \a x diff --git a/gecode/set/view/complement.hpp b/gecode/set/view/complement.hpp index 753bc4f4e2..3f441bfafa 100644 --- a/gecode/set/view/complement.hpp +++ b/gecode/set/view/complement.hpp @@ -38,10 +38,6 @@ namespace Gecode { namespace Set { - template - forceinline - ComplementView::ComplementView(void) {} - template forceinline ComplementView::ComplementView(View& y) @@ -351,7 +347,7 @@ namespace Gecode { namespace Set { /// \name Constructors and initialization //@{ /// Default constructor - LubRanges(void) {} + LubRanges(void) = default; /// Initialize with ranges for view \a x LubRanges(const ComplementView& x); /// Initialize with ranges for view \a x @@ -433,7 +429,7 @@ namespace Gecode { namespace Set { /// \name Constructors and initialization //@{ /// Default constructor - LubRanges(void) {} + LubRanges(void) = default; /// Initialize with ranges for view \a x LubRanges(const ComplementView>& x); /// Initialize with ranges for view \a x @@ -466,7 +462,7 @@ namespace Gecode { namespace Set { /// \name Constructors and initialization //@{ /// Default constructor - GlbRanges(void) {} + GlbRanges(void) = default; /// Initialize with ranges for view \a x GlbRanges(const ComplementView& x); /// Initialize with ranges for view \a x @@ -548,7 +544,7 @@ namespace Gecode { namespace Set { /// \name Constructors and initialization //@{ /// Default constructor - GlbRanges(void) {} + GlbRanges(void) = default; /// Initialize with ranges for view \a x GlbRanges(const ComplementView>& x); /// Initialize with ranges for view \a x diff --git a/gecode/set/view/const.hpp b/gecode/set/view/const.hpp index e573c2e679..9fe97289be 100644 --- a/gecode/set/view/const.hpp +++ b/gecode/set/view/const.hpp @@ -297,9 +297,6 @@ namespace Gecode { namespace Set { return false; } - forceinline - EmptyView::EmptyView(void) {} - forceinline unsigned int EmptyView::glb_size(void) const { return 0; @@ -455,9 +452,6 @@ namespace Gecode { namespace Set { // Constant universe variable - forceinline - UniverseView::UniverseView(void) {} - forceinline unsigned int UniverseView::glb_size(void) const { return Set::Limits::card; @@ -626,7 +620,7 @@ namespace Gecode { namespace Set { /// \name Constructors and initialization //@{ /// Default constructor - LubRanges(void) {} + LubRanges(void) = default; /// Initialize with ranges for view \a x LubRanges(const EmptyView& x) { (void)x; @@ -649,7 +643,7 @@ namespace Gecode { namespace Set { /// \name Constructors and initialization //@{ /// Default constructor - GlbRanges(void) {} + GlbRanges(void) = default; /// Initialize with ranges for view \a x GlbRanges(const EmptyView& x) { (void)x; @@ -721,6 +715,7 @@ namespace Gecode { namespace Set { /// \name Constructors and initialization //@{ /// Default constructor + // NOLINTNEXTLINE(modernize-use-equals-default) LubRanges(void) {} /// Initialize with ranges for view \a x LubRanges(const ConstSetView& x) : ar(x.ranges, x.size) {} @@ -775,6 +770,7 @@ namespace Gecode { namespace Set { /// \name Constructors and initialization //@{ /// Default constructor + // NOLINTNEXTLINE(modernize-use-equals-default) GlbRanges(void) {} /// Initialize with ranges for view \a x GlbRanges(const ConstSetView& x) : LubRanges(x) {} diff --git a/gecode/set/view/set.hpp b/gecode/set/view/set.hpp index bb06c335cf..7693016fd4 100644 --- a/gecode/set/view/set.hpp +++ b/gecode/set/view/set.hpp @@ -43,8 +43,6 @@ namespace Gecode { namespace Set { * */ - forceinline - SetView::SetView(void) {} forceinline SetView::SetView(const SetVar& y) : VarImpView(y.varimp()) {} @@ -222,6 +220,7 @@ namespace Gecode { namespace Set { }; forceinline + // NOLINTNEXTLINE(modernize-use-equals-default) LubRanges::LubRanges(void) {} forceinline @@ -251,6 +250,7 @@ namespace Gecode { namespace Set { }; forceinline + // NOLINTNEXTLINE(modernize-use-equals-default) GlbRanges::GlbRanges(void) {} forceinline diff --git a/gecode/set/view/singleton.hpp b/gecode/set/view/singleton.hpp index fc676d0ea8..06371c5fb6 100644 --- a/gecode/set/view/singleton.hpp +++ b/gecode/set/view/singleton.hpp @@ -36,9 +36,6 @@ namespace Gecode { namespace Set { - forceinline - SingletonView::SingletonView(void) {} - forceinline SingletonView::SingletonView(Gecode::Int::IntView& y) : DerivedView(y) {} @@ -351,6 +348,7 @@ namespace Gecode { namespace Set { }; forceinline + // NOLINTNEXTLINE(modernize-use-equals-default) LubRanges::LubRanges(void) {} forceinline @@ -402,6 +400,7 @@ namespace Gecode { namespace Set { }; forceinline + // NOLINTNEXTLINE(modernize-use-equals-default) GlbRanges::GlbRanges(void) {} forceinline void diff --git a/gecode/support/allocator.hpp b/gecode/support/allocator.hpp index 7fcfc1247f..3259f3b400 100644 --- a/gecode/support/allocator.hpp +++ b/gecode/support/allocator.hpp @@ -62,7 +62,7 @@ namespace Gecode { namespace Support { class Allocator { public: /// Default constructor - Allocator(void); + Allocator(void) = default; /// Allocate memory block of size \a n #ifdef GECODE_MIMALLOC GECODE_SUPPORT_EXPORT @@ -82,8 +82,6 @@ namespace Gecode { namespace Support { void* memcpy(void* d, const void* s, size_t n); }; - forceinline - Allocator::Allocator(void) {} #ifndef GECODE_MIMALLOC forceinline void* Allocator::alloc(size_t n) { diff --git a/gecode/support/bitset-base.hpp b/gecode/support/bitset-base.hpp index 9a8d6832d1..b9029c0530 100644 --- a/gecode/support/bitset-base.hpp +++ b/gecode/support/bitset-base.hpp @@ -124,13 +124,11 @@ namespace Gecode { namespace Support { /// Stored bits BitSetData* data; - private: + public: /// Copy constructor (disabled) - RawBitSetBase(const RawBitSetBase&); + RawBitSetBase(const RawBitSetBase&) = delete; /// Assignment operator (disabled) - RawBitSetBase& operator=(const RawBitSetBase&); - - public: + RawBitSetBase& operator=(const RawBitSetBase&) = delete; /// Default constructor (yields empty set) RawBitSetBase(void); /// Initialize for \a sz bits and allocator \a a @@ -177,13 +175,11 @@ namespace Gecode { namespace Support { /// Size of bitset (number of bits) unsigned int sz; - private: + public: /// Copy constructor (disabled) - BitSetBase(const BitSetBase&); + BitSetBase(const BitSetBase&) = delete; /// Assignment operator (disabled) - BitSetBase& operator=(const BitSetBase&); - - public: + BitSetBase& operator=(const BitSetBase&) = delete; /// Default constructor (yields empty set) BitSetBase(void); /// Initialize for \a s bits and allocator \a a diff --git a/gecode/support/heap.cpp b/gecode/support/heap.cpp index d04aeae59b..6b46b262d2 100644 --- a/gecode/support/heap.cpp +++ b/gecode/support/heap.cpp @@ -34,13 +34,6 @@ namespace Gecode { - Heap::Heap(void) -#ifdef GECODE_PEAKHEAP - : _peak(0), _cur(0) -#endif - { - } - Heap heap; } // namespace Gecode diff --git a/gecode/support/heap.hpp b/gecode/support/heap.hpp index 20210c68bc..439e2668ba 100644 --- a/gecode/support/heap.hpp +++ b/gecode/support/heap.hpp @@ -64,7 +64,7 @@ namespace Gecode { class Heap { public: /// Default constructor (ensuring that only a single instance is created) - Heap(void); + Heap(void) = default; /// \name Typed allocation routines //@{ /** @@ -370,9 +370,9 @@ namespace Gecode { /// Mutex for accessing heap size Support::Mutex _m; /// Peak heap size - size_t _peak; + size_t _peak = 0; /// Current heap size - size_t _cur; + size_t _cur = 0; public: size_t peak(void); diff --git a/gecode/support/run-jobs.hpp b/gecode/support/run-jobs.hpp index 478d2c1944..ff25b5a5dd 100644 --- a/gecode/support/run-jobs.hpp +++ b/gecode/support/run-jobs.hpp @@ -39,7 +39,7 @@ namespace Gecode { namespace Support { /// Run a job with iterator index \a i virtual RetType run(int i) = 0; /// Destructor - virtual ~Job(void) {} + virtual ~Job(void) = default; }; /// Class to throw an exception to stop new jobs from being started @@ -177,7 +177,7 @@ namespace Gecode { namespace Support { : Runnable(true), job(j), master(m), idx(i) {} template - RunJobs::Worker::~Worker(void) {} + RunJobs::Worker::~Worker(void) = default; template inline int diff --git a/gecode/support/thread.hpp b/gecode/support/thread.hpp index 2b915c9cf1..b6b5cb495e 100644 --- a/gecode/support/thread.hpp +++ b/gecode/support/thread.hpp @@ -99,12 +99,10 @@ namespace Gecode { namespace Support { /// Free memory allocated from heap static void operator delete(void* p); - private: /// A mutex cannot be copied - Mutex(const Mutex&) {} + Mutex(const Mutex&) = delete; /// A mutex cannot be assigned - void - operator=(const Mutex&) {} + Mutex& operator=(const Mutex&) = delete; }; /** @@ -123,12 +121,10 @@ namespace Gecode { namespace Support { /// Leave lock ~Lock(void); - private: /// A lock cannot be copied - Lock(const Lock& l) : m(l.m) {} + Lock(const Lock&) = delete; /// A lock cannot be assigned - void - operator=(const Lock&) {} + Lock& operator=(const Lock&) = delete; }; /** @@ -158,12 +154,10 @@ namespace Gecode { namespace Support { /// Wait until the event becomes signalled void wait(void); - private: /// An event cannot be copied - Event(const Event&) {} + Event(const Event&) = delete; /// An event cannot be assigned - void - operator=(const Event&) {} + Event& operator=(const Event&) = delete; }; /** @@ -175,7 +169,7 @@ namespace Gecode { namespace Support { class Terminator { public: /// Destructor - virtual ~Terminator() {} + virtual ~Terminator() = default; /// The function that is called when the thread has terminated virtual void terminated(void) = 0; }; @@ -205,7 +199,7 @@ namespace Gecode { namespace Support { /// The function that is executed when the thread starts virtual void run(void) = 0; /// Destructor - virtual ~Runnable(void) {} + virtual ~Runnable(void) = default; /// Allocate memory from heap static void* operator new(size_t s); /// Free memory allocated from heap @@ -268,12 +262,10 @@ namespace Gecode { namespace Support { /// release globally acquired mutex \a m GECODE_SUPPORT_EXPORT static void release_global_mutex(Mutex* m); - private: /// A thread cannot be copied - Thread(const Thread&) {} + Thread(const Thread&) = delete; /// A thread cannot be assigned - void - operator=(const Thread&) {} + Thread& operator=(const Thread&) = delete; }; }} // namespace Gecode::Support diff --git a/misc/genvarimp.py b/misc/genvarimp.py index d22a5d0d7e..48d061da0d 100644 --- a/misc/genvarimp.py +++ b/misc/genvarimp.py @@ -664,7 +664,7 @@ def generate_header(files: List[Dict], out: List[str]) -> None: {d['class']}(Gecode::Space& home, {d['class']}& x); public: /// Constructor for creating static instance of variable - {d['class']}(void); + {d['class']}(void) = default; /// Constructor for creating variable {d['class']}(Gecode::Space& home); /// \\name Dependencies @@ -719,9 +719,6 @@ def generate_header(files: List[Dict], out: List[str]) -> None: if d["dispose"]: out.append( f""" - forceinline - {d['class']}::{d['class']}(void) {{}} - forceinline {d['class']}::{d['class']}(Gecode::Space& home) : {d['base']}(home) {{ @@ -744,9 +741,6 @@ def generate_header(files: List[Dict], out: List[str]) -> None: else: out.append( f""" - forceinline - {d['class']}::{d['class']}(void) {{}} - forceinline {d['class']}::{d['class']}(Gecode::Space& home) : {d['base']}(home) {{}} diff --git a/test/array.cpp b/test/array.cpp index 1c1df8f79b..963947d0b1 100644 --- a/test/array.cpp +++ b/test/array.cpp @@ -240,6 +240,7 @@ namespace Test { class TestSpace : public Gecode::Space { public: TestSpace(void) : Space() {} + // NOLINTNEXTLINE(modernize-use-equals-default) TestSpace(TestSpace& s) : Space(s) {} Space* copy(void) override { diff --git a/test/branch.cpp b/test/branch.cpp index df2d02a760..ca60c2bb41 100644 --- a/test/branch.cpp +++ b/test/branch.cpp @@ -1410,8 +1410,9 @@ namespace Test { namespace Branch { class EmptySpace : public Gecode::Space { public: /// Initialize space - EmptySpace(void) {} + EmptySpace(void) = default; /// Constructor for cloning \a s + // NOLINTNEXTLINE(modernize-use-equals-default) EmptySpace(EmptySpace& s) : Gecode::Space(s) {} /// Return the number of propagators unsigned int diff --git a/test/fault.cpp b/test/fault.cpp index 956ff8f5a5..66b29ff268 100644 --- a/test/fault.cpp +++ b/test/fault.cpp @@ -220,6 +220,7 @@ namespace Test { namespace Fault { ThrowingBrancher::post(*this); ThrowingBrancher::post(*this); } + // NOLINTNEXTLINE(modernize-use-equals-default) CloneCopySpace(CloneCopySpace& s) : Space(s) {} Space* copy(void) override { @@ -279,6 +280,7 @@ namespace Test { namespace Fault { NoticeDisposeActor::post(*this); } } + // NOLINTNEXTLINE(modernize-use-equals-default) NoticeDisposeSpace(NoticeDisposeSpace& s) : Space(s) {} Space* copy(void) override { @@ -288,7 +290,8 @@ namespace Test { namespace Fault { class MiniModelSpace : public Space { public: - MiniModelSpace(void) {} + MiniModelSpace(void) = default; + // NOLINTNEXTLINE(modernize-use-equals-default) MiniModelSpace(MiniModelSpace& s) : Space(s) {} Space* copy(void) override { @@ -349,7 +352,7 @@ namespace Test { namespace Fault { class FaultLocalHandle : public LocalHandle { public: - FaultLocalHandle(void) {} + FaultLocalHandle(void) = default; FaultLocalHandle(FaultLocalObject* o) : LocalHandle(o) {} void update(Space& home, FaultLocalHandle& h) { @@ -940,7 +943,7 @@ namespace Test { namespace Fault { public: static int disposed; - FaultBoolMisc(void) {} + FaultBoolMisc(void) = default; ~FaultBoolMisc(void) override { disposed++; } diff --git a/test/float.hpp b/test/float.hpp index e5ab7a142e..1ec35200ac 100644 --- a/test/float.hpp +++ b/test/float.hpp @@ -45,7 +45,7 @@ namespace Test { namespace Float { Assignment::size(void) const { return n; } - inline Assignment::~Assignment(void) {} + inline Assignment::~Assignment(void) = default; inline CpltAssignment::CpltAssignment(int n, const Gecode::FloatVal& d, Gecode::FloatNum s) : Assignment(n, d), dsv(new Gecode::FloatVal[static_cast(n)]), step(s) { diff --git a/test/float/arithmetic.cpp b/test/float/arithmetic.cpp index 9abf6e8096..ed779365bc 100644 --- a/test/float/arithmetic.cpp +++ b/test/float/arithmetic.cpp @@ -1683,6 +1683,7 @@ namespace Test { namespace Float { /// Create fixture EmptyFixture(void) = default; /// Constructor for cloning \a fixture + // NOLINTNEXTLINE(modernize-use-equals-default) EmptyFixture(EmptyFixture& fixture) : Gecode::Space(fixture) {} /// Copy during cloning Gecode::Space* diff --git a/test/int.hpp b/test/int.hpp index d01869e29c..8a80863572 100644 --- a/test/int.hpp +++ b/test/int.hpp @@ -43,7 +43,7 @@ namespace Test { namespace Int { Assignment::size(void) const { return n; } - inline Assignment::~Assignment(void) {} + inline Assignment::~Assignment(void) = default; inline CpltAssignment::CpltAssignment(int n, const Gecode::IntSet& d) : Assignment(n, d), dsv(new Gecode::IntSetValues[static_cast(n)]) { diff --git a/test/int/bin-packing.cpp b/test/int/bin-packing.cpp index 9125652607..0cbbe3a133 100644 --- a/test/int/bin-packing.cpp +++ b/test/int/bin-packing.cpp @@ -257,7 +257,7 @@ namespace Test { namespace Int { class TestSpace : public Gecode::Space { public: // Constructor - TestSpace(void) {} + TestSpace(void) = default; // Copy function Gecode::Space* copy(void) override { @@ -322,7 +322,7 @@ namespace Test { namespace Int { /// Simple test space class class TestSpace : public Gecode::Space { public: - TestSpace(void) {} + TestSpace(void) = default; Gecode::Space* copy(void) override { return nullptr; @@ -367,6 +367,7 @@ namespace Test { namespace Int { class Fixture : public Gecode::Space { public: Fixture(void) = default; + // NOLINTNEXTLINE(modernize-use-equals-default) Fixture(Fixture& fixture) : Gecode::Space(fixture) {} Gecode::Space* copy(void) override { diff --git a/test/int/cumulative.cpp b/test/int/cumulative.cpp index f3726e25d6..fcce063494 100644 --- a/test/int/cumulative.cpp +++ b/test/int/cumulative.cpp @@ -613,6 +613,7 @@ namespace Test { namespace Int { } Gecode::cumulative(*this, 3, starts, processing, demand, mandatory, level); } + // NOLINTNEXTLINE(modernize-use-equals-default) OptionalSubsetFixture(OptionalSubsetFixture& fixture) : Gecode::Space(fixture) {} Gecode::Space* copy(void) override { diff --git a/test/int/distinct.cpp b/test/int/distinct.cpp index 61d44c15c7..9c68b5938d 100644 --- a/test/int/distinct.cpp +++ b/test/int/distinct.cpp @@ -210,8 +210,9 @@ namespace Test { namespace Int { class TestSpace : public Gecode::Space { public: /// Constructor - TestSpace(void) {} + TestSpace(void) = default; /// Constructor for cloning \a s + // NOLINTNEXTLINE(modernize-use-equals-default) TestSpace(TestSpace& s) : Gecode::Space(s) {} /// Copy space during cloning Gecode::Space* diff --git a/test/int/gcc.cpp b/test/int/gcc.cpp index 7549f1d0f5..68a6299a74 100644 --- a/test/int/gcc.cpp +++ b/test/int/gcc.cpp @@ -310,6 +310,7 @@ namespace Test { namespace Int { class Fixture : public Gecode::Space { public: Fixture(void) = default; + // NOLINTNEXTLINE(modernize-use-equals-default) Fixture(Fixture& fixture) : Gecode::Space(fixture) {} Gecode::Space* copy(void) override { diff --git a/test/int/no-overlap.cpp b/test/int/no-overlap.cpp index e9f6aa9db0..c902913828 100644 --- a/test/int/no-overlap.cpp +++ b/test/int/no-overlap.cpp @@ -273,6 +273,7 @@ namespace Test { namespace Int { class Fixture : public Gecode::Space { public: Fixture(void) = default; + // NOLINTNEXTLINE(modernize-use-equals-default) Fixture(Fixture& fixture) : Gecode::Space(fixture) {} Gecode::Space* copy(void) override { diff --git a/test/int/open-var-list.cpp b/test/int/open-var-list.cpp index 749165dc4f..749773c867 100644 --- a/test/int/open-var-list.cpp +++ b/test/int/open-var-list.cpp @@ -1093,7 +1093,7 @@ namespace Test { namespace Int { namespace OpenList { public: Gecode::Int::GrowableIntSet values; - SetSpace(void) {} + SetSpace(void) = default; SetSpace(SetSpace& s) : Gecode::Space(s) { values.update(*this, s.values); diff --git a/test/region.cpp b/test/region.cpp index 615e34020a..94153ade6a 100644 --- a/test/region.cpp +++ b/test/region.cpp @@ -71,8 +71,9 @@ namespace Test { class EmptySpace : public Gecode::Space { public: /// Initialize space - EmptySpace(void) {} + EmptySpace(void) = default; /// Constructor for cloning \a s + // NOLINTNEXTLINE(modernize-use-equals-default) EmptySpace(EmptySpace& s) : Gecode::Space(s) {} /// Copy space during cloning Gecode::Space* diff --git a/test/search.cpp b/test/search.cpp index 27ef3cfaba..e9db08025b 100644 --- a/test/search.cpp +++ b/test/search.cpp @@ -146,6 +146,7 @@ namespace Test { : graph(std::move(g)), maximize(max), vertex(0), ceiling(std::numeric_limits::max()) { (void)new (*this) Decisions(*this); } + // NOLINTNEXTLINE(modernize-use-equals-default) TreeSpace(TreeSpace& s) : Space(s), graph(s.graph), maximize(s.maximize), vertex(s.vertex), ceiling(s.ceiling) {} Space* @@ -401,8 +402,9 @@ namespace Test { class TestSpace : public Space { public: /// Constructor for space creation - TestSpace(void) {} + TestSpace(void) = default; /// Constructor for cloning \a s + // NOLINTNEXTLINE(modernize-use-equals-default) TestSpace(TestSpace& s) : Space(s) {} /// Return number of solutions virtual int solutions(void) const = 0; @@ -852,6 +854,7 @@ namespace Test { /// Initialize with shared observations \a s HubDispatchSpace(MetaDispatchState& s) : MetaDispatchSpace(s) {} /// Clone \a s + // NOLINTNEXTLINE(modernize-use-equals-default) HubDispatchSpace(HubDispatchSpace& s) : MetaDispatchSpace(s) {} /// Copy during cloning Space* @@ -871,6 +874,7 @@ namespace Test { /// Initialize with shared observations \a s SpokeDispatchSpace(MetaDispatchState& s) : MetaDispatchSpace(s) {} /// Clone \a s + // NOLINTNEXTLINE(modernize-use-equals-default) SpokeDispatchSpace(SpokeDispatchSpace& s) : MetaDispatchSpace(s) {} /// Copy during cloning Space* @@ -890,6 +894,7 @@ namespace Test { /// Initialize with shared observations \a s HubSpokeDispatchSpace(MetaDispatchState& s) : MetaDispatchSpace(s) {} /// Clone \a s + // NOLINTNEXTLINE(modernize-use-equals-default) HubSpokeDispatchSpace(HubSpokeDispatchSpace& s) : MetaDispatchSpace(s) {} /// Copy during cloning Space* @@ -1952,6 +1957,7 @@ namespace Test { class IncomparableObjective : public ExternalObjective { public: IncomparableObjective(int v) : ExternalObjective(v) {} + // NOLINTNEXTLINE(modernize-use-equals-default) IncomparableObjective(IncomparableObjective& s) : ExternalObjective(s) {} Space* copy(void) override { @@ -1966,7 +1972,8 @@ namespace Test { /// Search model without objective comparison support class UnsupportedObjective : public Space { public: - UnsupportedObjective(void) {} + UnsupportedObjective(void) = default; + // NOLINTNEXTLINE(modernize-use-equals-default) UnsupportedObjective(UnsupportedObjective& s) : Space(s) {} Space* copy(void) override { @@ -2573,7 +2580,8 @@ namespace Test { /// Space without objective comparison support class PlainSpace : public Space { public: - PlainSpace(void) {} + PlainSpace(void) = default; + // NOLINTNEXTLINE(modernize-use-equals-default) PlainSpace(PlainSpace& s) : Space(s) {} Space* copy(void) override { @@ -2656,6 +2664,7 @@ namespace Test { class Fixture : public Gecode::Space { public: Fixture(void) = default; + // NOLINTNEXTLINE(modernize-use-equals-default) Fixture(Fixture& fixture) : Gecode::Space(fixture) {} Gecode::Space* copy(void) override { @@ -3125,6 +3134,7 @@ namespace Test { class FailingHub : public NoSolution { public: FailingHub(void) = default; + // NOLINTNEXTLINE(modernize-use-equals-default) FailingHub(FailingHub& s) : NoSolution(s) {} Gecode::Space* copy(void) override { @@ -3173,6 +3183,7 @@ namespace Test { class FailingSpoke : public NoSolution { public: FailingSpoke(void) = default; + // NOLINTNEXTLINE(modernize-use-equals-default) FailingSpoke(FailingSpoke& s) : NoSolution(s) {} Gecode::Space* copy(void) override { @@ -3233,6 +3244,7 @@ namespace Test { class FailingFirstSpoke : public RestrictedFirstSpoke { public: FailingFirstSpoke(void) = default; + // NOLINTNEXTLINE(modernize-use-equals-default) FailingFirstSpoke(FailingFirstSpoke& s) : RestrictedFirstSpoke(s) {} Gecode::Space* copy(void) override { @@ -3431,6 +3443,7 @@ namespace Test { std::vector* defaults; IncompleteEpisodes(Gecode::SpokeCoverage c, std::vector& d) : coverage(c), defaults(&d) {} + // NOLINTNEXTLINE(modernize-use-equals-default) IncompleteEpisodes(IncompleteEpisodes& s) : NoSolution(s), coverage(s.coverage), defaults(s.defaults) {} Gecode::Space* copy(void) override { @@ -3492,6 +3505,7 @@ namespace Test { class RelaxSpace : public Gecode::Space { public: RelaxSpace(void) = default; + // NOLINTNEXTLINE(modernize-use-equals-default) RelaxSpace(RelaxSpace& s) : Gecode::Space(s) {} Gecode::Space* copy(void) override { @@ -3849,6 +3863,7 @@ namespace Test { class IllegalContinue : public NoSolution { public: IllegalContinue(void) = default; + // NOLINTNEXTLINE(modernize-use-equals-default) IllegalContinue(IllegalContinue& s) : NoSolution(s) {} Gecode::Space* copy(void) override { @@ -4477,6 +4492,7 @@ namespace Test { class FailingAsset : public NoSolution { public: FailingAsset(void) = default; + // NOLINTNEXTLINE(modernize-use-equals-default) FailingAsset(FailingAsset& s) : NoSolution(s) {} Gecode::Space* copy(void) override { diff --git a/test/set.hh b/test/set.hh index 9413498d7b..bea3f03586 100644 --- a/test/set.hh +++ b/test/set.hh @@ -77,7 +77,7 @@ namespace Test { public: /// Default constructor - CountableSetValues(void) {} + CountableSetValues(void) = default; /// Initialize with set \a d0 and bit-pattern \a cur0 CountableSetValues(const Gecode::IntSet& d0, int cur0) : dv(d0), cur(cur0), i(1) { if (!(i & cur)) @@ -120,7 +120,7 @@ namespace Test { public: /// Default constructor - CountableSetRanges(void) {} + CountableSetRanges(void) = default; /// Initialize with set \a d0 and bit-pattern \a cur0 CountableSetRanges(const Gecode::IntSet& d, int cur) : v(d, cur) { Gecode::Iter::Values::ToRanges::init(v); @@ -147,7 +147,7 @@ namespace Test { /// Initialize with set \a s CountableSet(const Gecode::IntSet& s); /// Default constructor - CountableSet(void) {} + CountableSet(void) = default; /// Initialize with set \a s void init(const Gecode::IntSet& s); /// Check if still subsets left From 55df27c77bdf3169344cef544708a301df720cdd Mon Sep 17 00:00:00 2001 From: Mikael Zayenz Lagerkvist Date: Wed, 4 Nov 2026 06:21:02 +0100 Subject: [PATCH 3/4] Use operator<=> and defaulted operator== where they keep semantics Support::BitSetData now has a defaulted operator==, and Int::LDSB::Literal replaces its operator< with a defaulted operator<=>. operator!= goes from PropagatorGroup, BrancherGroup, DFA, IntSet, Int::BinPacking::Item, space_allocator, region_allocator, and the integer, set, and float views, where it only negated operator== and C++20 rewrites a != b. TupleSet keeps its operator!=: without it, true != t is ambiguous between its int constructor and its bool conversion. The FloatVal interval comparisons, the minimodel expression builders, the kernel's heterogeneous view templates, and the classes whose order is not member order are unchanged. Int::CachedView::operator== called a nonexistent offset() and now compares base(). New tests compare each converted class, docs/code-style.md states the rule, and the changelog names the removed operators. These are reviewed hand edits per inventory row; build/zdev-impl/modern-classes-004/scripts/rgchecks.sh-style searches for explicit operator calls (rg 'operator\s*(==|!=|<)\s*\(' and '(\.|->)operator') found callers only in the excluded minimodel set relations. Zdev-Change-Id: Zda6679a68a585cb61e38e90ad2b04ace5898e18e7cf9441b76d21246b9953071 --- changelog.in | 30 ++++++++++++ docs/code-style.md | 23 ++++++++++ gecode/float/view.hpp | 9 ---- gecode/float/view/minus.hpp | 4 -- gecode/float/view/offset.hpp | 4 -- gecode/float/view/scale.hpp | 4 -- gecode/int.hh | 13 ++++-- gecode/int/bin-packing.hh | 2 - gecode/int/bin-packing/propagate.hpp | 4 -- gecode/int/extensional/dfa.hpp | 5 -- gecode/int/int-set-1.hpp | 5 -- gecode/int/ldsb.hh | 7 +-- gecode/int/ldsb/brancher.hpp | 11 ----- gecode/int/view.hpp | 23 ---------- gecode/int/view/cached.hpp | 7 +-- gecode/int/view/constint.hpp | 4 -- gecode/int/view/minus.hpp | 4 -- gecode/int/view/neg-bool.hpp | 4 -- gecode/int/view/offset.hpp | 4 -- gecode/int/view/scale.hpp | 5 -- gecode/int/view/zero.hpp | 4 -- gecode/kernel/core.hpp | 12 ----- gecode/kernel/memory/allocators.hpp | 24 ---------- gecode/set/view.hpp | 22 --------- gecode/set/view/cached.hpp | 6 --- gecode/set/view/complement.hpp | 6 --- gecode/set/view/const.hpp | 14 +----- gecode/set/view/singleton.hpp | 5 -- gecode/support/bitset-base.hpp | 14 +----- test/float/basic.cpp | 40 +++++++++++++++- test/groups.cpp | 21 +++++++++ test/int/basic.cpp | 68 ++++++++++++++++++++++++++++ test/int/bin-packing.cpp | 34 ++++++++++++++ test/int/extensional.cpp | 62 +++++++++++++++++++++++++ test/ldsb.cpp | 20 ++++++++ test/region.cpp | 55 +++++++++++++++------- test/set/construct.cpp | 43 ++++++++++++++++++ test/test.hh | 10 ++++ test/test.hpp | 12 +++++ 39 files changed, 417 insertions(+), 227 deletions(-) diff --git a/changelog.in b/changelog.in index bb2476baa5..476b6b645e 100644 --- a/changelog.in +++ b/changelog.in @@ -129,6 +129,36 @@ Iter::Ranges and Iter::Values, and the range and value iterators of views such as Int::ViewRanges and Set::UnknownRanges. It also affects SetRel, FreeList, Float::OffsetView, and Search::TraceRecorder::ID. +[ENTRY] +Module: kernel +What: change +Rank: minor +[DESCRIPTION] +Remove operator!= where it only negated operator==, and replace the +operator< of Int::LDSB::Literal with a defaulted operator<=>. C++20 rewrites +`a != b` as `!(a == b)` and `a < b` through operator<=>, so these expressions +keep their results. A call that names the operator, such as +`operator!=(a, b)` or `a.operator<(b)`, no longer compiles; write the +expression instead. +[MORE] +operator!= is removed from PropagatorGroup, BrancherGroup, IntSet, DFA, +Support::BitSetData, space_allocator, region_allocator, +Int::BinPacking::Item, and the integer, set, and float views. The kernel's +ConstView, VarImpView, and DerivedView templates keep theirs, and so does +TupleSet: without it, `true != t` would be ambiguous between its int +constructor and its bool conversion. +Support::BitSetData::operator== is now defaulted and takes its argument by +const reference. Int::LDSB::Literal now also has ==, !=, <=, >, and >=. + +[ENTRY] +Module: int +What: bug +Rank: minor +[DESCRIPTION] +Fix operator== of Int::CachedView. It used a member that the view does not +have, so comparing two cached integer views did not compile. It now compares +the base views, like Set::CachedView. + [ENTRY] Module: support What: removed diff --git a/docs/code-style.md b/docs/code-style.md index c69d8cef48..156897d9f8 100644 --- a/docs/code-style.md +++ b/docs/code-style.md @@ -162,6 +162,29 @@ heap zero a class whose default constructor is not user-provided, while the empty constructor leaves fields without an initializer untouched. A constructor whose body is empty only in some configurations stays as well. +Comparisons use the C++20 forms. A class whose equality compares every field +declares `bool operator==(const T&) const = default;`. A class ordered +lexicographically by its fields in declaration order declares +`auto operator<=>(const T&) const = default;` instead, which also provides +`==`; its header includes ``. Declare no `operator!=` and no `<`, +`<=`, `>`, or `>=` beside them: the compiler rewrites `a != b` as +`!(a == b)` and the relational operators through `operator<=>`, in either +argument order. A hand-written `operator==` stays where equality is not +field-wise, for example a deep comparison of a shared object or a comparison +of the address an allocator refers to, and it gets no `operator!=` either. A +hand-written `operator<` stays where the order is not the field order, such +as a sort key. Operators that build modelling expressions, such as +`IntVar < IntVar`, keep all their operators, and so do the possibly/certainly +interval comparisons of `FloatVal`. The kernel's heterogeneous `ConstView`, +`VarImpView`, and `DerivedView` templates keep `operator!=`: without it, their +reversed `operator==` candidates would join every view comparison. A class +with both an implicit converting constructor and an implicit conversion +operator keeps `operator!=` as well. `TupleSet` is one: without its +`operator!=`, `true != t` is ambiguous between its `int` constructor and its +`bool` conversion. Rewriting +covers only operator expressions, so write `a != b`, not `operator!=(a, b)` or +`a.operator<(b)`. No clang-tidy check enforces this rule. + Other performance checks need focused review: `performance-enum-size` changes layouts and ABI, and `performance-no-int-to-ptr` conflicts with deliberate pointer tagging. Review `noexcept` guarantees, destructor triviality, and math diff --git a/gecode/float/view.hpp b/gecode/float/view.hpp index 4721968983..e20b19464e 100644 --- a/gecode/float/view.hpp +++ b/gecode/float/view.hpp @@ -248,9 +248,6 @@ namespace Gecode { namespace Float { /// Test whether views \a x and \a y are the same /// \relates Gecode::Float::MinusView bool operator==(const MinusView& x, const MinusView& y); - /// Test whether views \a x and \a y are not the same - /// \relates Gecode::Float::MinusView - bool operator!=(const MinusView& x, const MinusView& y); //@} /** @@ -376,9 +373,6 @@ namespace Gecode { namespace Float { /// Test whether views \a x and \a y are the same /// \relates Gecode::Float::OffsetView bool operator==(const OffsetView& x, const OffsetView& y); - /// Test whether views \a x and \a y are not the same - /// \relates Gecode::Float::OffsetView - bool operator!=(const OffsetView& x, const OffsetView& y); //@} /** @@ -504,9 +498,6 @@ namespace Gecode { namespace Float { /// Test whether views \a x and \a y are the same /// \relates Gecode::Float::ScaleView bool operator==(const ScaleView& x, const ScaleView& y); - /// Test whether views \a x and \a y are not the same - /// \relates Gecode::Float::ScaleView - bool operator!=(const ScaleView& x, const ScaleView& y); //@} }} // namespace Gecode::Float diff --git a/gecode/float/view/minus.hpp b/gecode/float/view/minus.hpp index 10ca5cbdd9..77b56477f5 100644 --- a/gecode/float/view/minus.hpp +++ b/gecode/float/view/minus.hpp @@ -158,10 +158,6 @@ namespace Gecode { namespace Float { operator==(const MinusView& x, const MinusView& y) { return x.base() == y.base(); } - forceinline bool - operator!=(const MinusView& x, const MinusView& y) { - return !(x == y); - } }} // namespace Gecode::Float diff --git a/gecode/float/view/offset.hpp b/gecode/float/view/offset.hpp index ead5a08560..4a8ee15dfc 100644 --- a/gecode/float/view/offset.hpp +++ b/gecode/float/view/offset.hpp @@ -185,10 +185,6 @@ namespace Gecode { namespace Float { operator==(const OffsetView& x, const OffsetView& y) { return (x.base() == y.base()) && (x.offset() == y.offset()); } - forceinline bool - operator!=(const OffsetView& x, const OffsetView& y) { - return !(x == y); - } }} // namespace Gecode::Float diff --git a/gecode/float/view/scale.hpp b/gecode/float/view/scale.hpp index 6ff5e1052f..5f2ff1ea9a 100644 --- a/gecode/float/view/scale.hpp +++ b/gecode/float/view/scale.hpp @@ -213,10 +213,6 @@ namespace Gecode { namespace Float { operator==(const ScaleView& x, const ScaleView& y) { return (x.base() == y.base()) && (x.scale() == y.scale()); } - forceinline bool - operator!=(const ScaleView& x, const ScaleView& y) { - return !(x == y); - } }} // namespace Gecode::Float diff --git a/gecode/int.hh b/gecode/int.hh index e626631bea..b4a61a4036 100644 --- a/gecode/int.hh +++ b/gecode/int.hh @@ -288,8 +288,6 @@ namespace Gecode { //@{ /// Return whether \a s is equal bool operator==(const IntSet& s) const; - /// Return whether \a s is not equal - bool operator!=(const IntSet& s) const; //@} /// \name Predefined value @@ -2547,8 +2545,6 @@ namespace Gecode { /// Test whether DFA is equal to \a d GECODE_INT_EXPORT bool operator==(const DFA& d) const; - /// Test whether DFA is not equal to \a d - bool operator!=(const DFA& d) const; /// Return the number of states int n_states(void) const; /// Return the number of transitions @@ -2804,7 +2800,14 @@ namespace Gecode { operator bool(void) const; /// Test whether tuple set is equal to \a t bool operator==(const TupleSet& t) const; - /// Test whether tuple set is different from \a t + /** + * \brief Test whether tuple set is different from \a t + * + * Kept although C++20 rewrites \c != from \c ==: without it, the + * reversed \c == candidates make \c true \c != \c t ambiguous, + * because the implicit \c int constructor competes with the + * implicit \c bool conversion. + */ bool operator!=(const TupleSet& t) const; //@} diff --git a/gecode/int/bin-packing.hh b/gecode/int/bin-packing.hh index ba24cf4dae..01b4a4b46e 100644 --- a/gecode/int/bin-packing.hh +++ b/gecode/int/bin-packing.hh @@ -78,8 +78,6 @@ namespace Gecode { namespace Int { namespace BinPacking { /// Whether two items are the same bool operator==(const Item& i, const Item& j); - /// Whether two items are not the same - bool operator!=(const Item& i, const Item& j); /// Order, also for sorting according to size bool operator<(const Item& i, const Item& j); diff --git a/gecode/int/bin-packing/propagate.hpp b/gecode/int/bin-packing/propagate.hpp index fc169b48b4..d3fcaf0552 100644 --- a/gecode/int/bin-packing/propagate.hpp +++ b/gecode/int/bin-packing/propagate.hpp @@ -74,10 +74,6 @@ namespace Gecode { namespace Int { namespace BinPacking { operator==(const Item& i, const Item& j) { return (i.bin() == j.bin()) && (i.size() == j.size()); } - forceinline bool - operator!=(const Item& i, const Item& j) { - return !(i == j); - } /// For sorting according to size forceinline bool diff --git a/gecode/int/extensional/dfa.hpp b/gecode/int/extensional/dfa.hpp index 770c0c9134..b07fe7c05c 100644 --- a/gecode/int/extensional/dfa.hpp +++ b/gecode/int/extensional/dfa.hpp @@ -327,11 +327,6 @@ namespace Gecode { return equal(d); } - forceinline bool - DFA::operator!=(const DFA& d) const { - return !(*this == d); - } - } // namespace Gecode // STATISTICS: int-prop diff --git a/gecode/int/int-set-1.hpp b/gecode/int/int-set-1.hpp index b6eff1f0a0..f39d5678d9 100644 --- a/gecode/int/int-set-1.hpp +++ b/gecode/int/int-set-1.hpp @@ -222,11 +222,6 @@ namespace Gecode { return o1->equal(*o2); } - forceinline bool - IntSet::operator!=(const IntSet& s) const { - return !(*this == s); - } - /* * Range iterator for integer sets * diff --git a/gecode/int/ldsb.hh b/gecode/int/ldsb.hh index 3afadc851f..22643517c7 100644 --- a/gecode/int/ldsb.hh +++ b/gecode/int/ldsb.hh @@ -35,6 +35,8 @@ #include +#include + /** * \namespace Gecode::Int::LDSB * \brief Symmetry breaking for integer variables @@ -57,9 +59,8 @@ namespace Gecode { namespace Int { namespace LDSB { /// one of the possible elements of the set. int _value; - /// Less than. The ordering is the lexicographical order - /// on the (variable,value) pair. - bool operator<(const Literal& rhs) const; + /// Order lexicographically by variable index, then by value + auto operator<=>(const Literal&) const = default; }; /** diff --git a/gecode/int/ldsb/brancher.hpp b/gecode/int/ldsb/brancher.hpp index c8056c7812..28f2d14bc3 100644 --- a/gecode/int/ldsb/brancher.hpp +++ b/gecode/int/ldsb/brancher.hpp @@ -43,17 +43,6 @@ namespace Gecode { namespace Int { namespace LDSB { Literal::Literal(int idx, int val) : _variable(idx), _value(val) {} - forceinline bool - Literal::operator<(const Literal& rhs) const { - int d = rhs._variable - _variable; - if (d > 0) - return true; - else if (d == 0) - return rhs._value > _value; - else - return false; - } - template inline LDSBChoice::LDSBChoice(const Brancher& b, unsigned int a, const Pos& p, const Val& n, const Literal* literals, int nliterals) diff --git a/gecode/int/view.hpp b/gecode/int/view.hpp index 6711746abd..c1f56d2ffb 100644 --- a/gecode/int/view.hpp +++ b/gecode/int/view.hpp @@ -425,9 +425,6 @@ namespace Gecode { namespace Int { /// Test whether views \a x and \a y are the same /// \relates Gecode::Int::MinusView bool operator==(const MinusView& x, const MinusView& y); - /// Test whether views \a x and \a y are not the same - /// \relates Gecode::Int::MinusView - bool operator!=(const MinusView& x, const MinusView& y); //@} /** @@ -604,9 +601,6 @@ namespace Gecode { namespace Int { /// Test whether views \a x and \a y are the same /// \relates Gecode::Int::OffsetView bool operator==(const OffsetView& x, const OffsetView& y); - /// Test whether views \a x and \a y are not the same - /// \relates Gecode::Int::OffsetView - bool operator!=(const OffsetView& x, const OffsetView& y); //@} /** @@ -832,10 +826,6 @@ namespace Gecode { namespace Int { /// \relates Gecode::Int::ScaleView template bool operator==(const ScaleView& x, const ScaleView& y); - /// Test whether views \a x and \a y are not the same - /// \relates Gecode::Int::ScaleView - template - bool operator!=(const ScaleView& x, const ScaleView& y); //@} /** @@ -994,9 +984,6 @@ namespace Gecode { namespace Int { /// Test whether views \a x and \a y are the same /// \relates Gecode::Int::ConstIntView bool operator==(const ConstIntView& x, const ConstIntView& y); - /// Test whether views \a x and \a y are not the same - /// \relates Gecode::Int::ConstIntView - bool operator!=(const ConstIntView& x, const ConstIntView& y); //@} /** @@ -1138,9 +1125,6 @@ namespace Gecode { namespace Int { /// Test whether views \a x and \a y are the same /// \relates Gecode::Int::ZeroIntView bool operator==(const ZeroIntView& x, const ZeroIntView& y); - /// Test whether views \a x and \a y are the same - /// \relates Gecode::Int::ZeroIntView - bool operator!=(const ZeroIntView& x, const ZeroIntView& y); //@} template @@ -1330,10 +1314,6 @@ namespace Gecode { namespace Int { /// \relates Gecode::Int::CachedView template bool operator==(const CachedView& x, const CachedView& y); - /// Test whether views \a x and \a y are not the same - /// \relates Gecode::Int::CachedView - template - bool operator!=(const CachedView& x, const CachedView& y); //@} /** @@ -1682,9 +1662,6 @@ namespace Gecode { namespace Int { /// Test whether views \a x and \a y are the same /// \relates Gecode::Int::NegBoolView bool operator==(const NegBoolView& x, const NegBoolView& y); - /// Test whether views \a x and \a y are not the same - /// \relates Gecode::Int::NegBoolView - bool operator!=(const NegBoolView& x, const NegBoolView& y); //@} /** diff --git a/gecode/int/view/cached.hpp b/gecode/int/view/cached.hpp index 1e9386175e..a9028fbbb2 100644 --- a/gecode/int/view/cached.hpp +++ b/gecode/int/view/cached.hpp @@ -376,12 +376,7 @@ namespace Gecode { namespace Int { template forceinline bool operator==(const CachedView& x, const CachedView& y) { - return (x.base() == y.base()) && (x.offset() == y.offset()); - } - template - forceinline bool - operator!=(const CachedView& x, const CachedView& y) { - return !(x == y); + return x.base() == y.base(); } }} // namespace Gecode::Int diff --git a/gecode/int/view/constint.hpp b/gecode/int/view/constint.hpp index a26d5d3463..f368123042 100644 --- a/gecode/int/view/constint.hpp +++ b/gecode/int/view/constint.hpp @@ -313,10 +313,6 @@ namespace Gecode { namespace Int { operator==(const ConstIntView& x, const ConstIntView& y) { return x.min() == y.min(); } - forceinline bool - operator!=(const ConstIntView& x, const ConstIntView& y) { - return !(x == y); - } }} // namespace Gecode::Int diff --git a/gecode/int/view/minus.hpp b/gecode/int/view/minus.hpp index d34b81f39e..0dc85a15bc 100644 --- a/gecode/int/view/minus.hpp +++ b/gecode/int/view/minus.hpp @@ -308,10 +308,6 @@ namespace Gecode { namespace Int { operator==(const MinusView& x, const MinusView& y) { return x.base() == y.base(); } - forceinline bool - operator!=(const MinusView& x, const MinusView& y) { - return !(x == y); - } }} // namespace Gecode::Int diff --git a/gecode/int/view/neg-bool.hpp b/gecode/int/view/neg-bool.hpp index a56b261b4c..eb7d045aac 100644 --- a/gecode/int/view/neg-bool.hpp +++ b/gecode/int/view/neg-bool.hpp @@ -205,10 +205,6 @@ namespace Gecode { namespace Int { operator==(const NegBoolView& x, const NegBoolView& y) { return x.base() == y.base(); } - forceinline bool - operator!=(const NegBoolView& x, const NegBoolView& y) { - return !(x == y); - } /** * \brief %Range iterator for negated Boolean variable views diff --git a/gecode/int/view/offset.hpp b/gecode/int/view/offset.hpp index b7bffc1121..5216605795 100644 --- a/gecode/int/view/offset.hpp +++ b/gecode/int/view/offset.hpp @@ -302,10 +302,6 @@ namespace Gecode { namespace Int { operator==(const OffsetView& x, const OffsetView& y) { return (x.base() == y.base()) && (x.offset() == y.offset()); } - forceinline bool - operator!=(const OffsetView& x, const OffsetView& y) { - return !(x == y); - } }} // namespace Gecode::Int diff --git a/gecode/int/view/scale.hpp b/gecode/int/view/scale.hpp index 018dde0a17..fc660fe722 100644 --- a/gecode/int/view/scale.hpp +++ b/gecode/int/view/scale.hpp @@ -294,11 +294,6 @@ namespace Gecode { namespace Int { operator==(const ScaleView& x, const ScaleView& y) { return (x.base() == y.base()) && (x.scale() == y.scale()); } - template - forceinline bool - operator!=(const ScaleView& x, const ScaleView& y) { - return !(x == y); - } }} // namespace Gecode::Int diff --git a/gecode/int/view/zero.hpp b/gecode/int/view/zero.hpp index ced621fb44..15ca93576e 100644 --- a/gecode/int/view/zero.hpp +++ b/gecode/int/view/zero.hpp @@ -288,10 +288,6 @@ namespace Gecode { namespace Int { operator==(const ZeroIntView&, const ZeroIntView&) { return true; } - forceinline bool - operator!=(const ZeroIntView&, const ZeroIntView&) { - return false; - } }} // namespace Gecode::Int diff --git a/gecode/kernel/core.hpp b/gecode/kernel/core.hpp index a3ffc6d5bb..8c476a6738 100644 --- a/gecode/kernel/core.hpp +++ b/gecode/kernel/core.hpp @@ -805,8 +805,6 @@ namespace Gecode { //@{ /// Test whether this group is equal to group \a g bool operator==(PropagatorGroup g) const; - /// Test whether this group is different from group \a g - bool operator!=(PropagatorGroup g) const; /// Return number of propagators in a group GECODE_KERNEL_EXPORT unsigned int size(Space& home) const; @@ -872,8 +870,6 @@ namespace Gecode { //@{ /// Test whether this group is equal to group \a g bool operator==(BrancherGroup g) const; - /// Test whether this group is different from group \a g - bool operator!=(BrancherGroup g) const; /// Return number of branchers in a group GECODE_KERNEL_EXPORT unsigned int size(Space& home) const; @@ -5571,10 +5567,6 @@ namespace Gecode { PropagatorGroup::operator==(PropagatorGroup g) const { return id() == g.id(); } - forceinline bool - PropagatorGroup::operator!=(PropagatorGroup g) const { - return id() != g.id(); - } forceinline PropagatorGroup& PropagatorGroup::move(Space&, Propagator& p) { @@ -5596,10 +5588,6 @@ namespace Gecode { BrancherGroup::operator==(BrancherGroup g) const { return id() == g.id(); } - forceinline bool - BrancherGroup::operator!=(BrancherGroup g) const { - return id() != g.id(); - } forceinline BrancherGroup& BrancherGroup::move(Space&, Brancher& p) { diff --git a/gecode/kernel/memory/allocators.hpp b/gecode/kernel/memory/allocators.hpp index 489cf093f5..1b8958f7e1 100644 --- a/gecode/kernel/memory/allocators.hpp +++ b/gecode/kernel/memory/allocators.hpp @@ -307,18 +307,6 @@ namespace Gecode { return &al1.space == &al2.space; } - /** - * \brief Tests two space allocators for inequality - * - * Two allocators are equal when each can release storage allocated - * from the other. - */ - template - bool - operator!=(space_allocator const& al1, space_allocator const& al2) noexcept { - return &al1.space != &al2.space; - } - template struct region_allocator; @@ -482,18 +470,6 @@ namespace Gecode { return &al1.region == &al2.region; } - /* - * \brief Tests two region allocators for inequality - * - * Two allocators are equal when each can release storage allocated - * from the other. - */ - template - bool - operator!=(region_allocator const& al1, region_allocator const& al2) noexcept { - return &al1.region != &al2.region; - } - } // namespace Gecode // STATISTICS: kernel-memory diff --git a/gecode/set/view.hpp b/gecode/set/view.hpp index b4a246d3bf..be05b833fa 100644 --- a/gecode/set/view.hpp +++ b/gecode/set/view.hpp @@ -173,7 +173,6 @@ namespace Gecode { namespace Set { // Forward declarations for friends class ConstSetView; bool operator==(const ConstSetView&, const ConstSetView&); - bool operator!=(const ConstSetView&, const ConstSetView&); /** * \brief Constant view @@ -186,7 +185,6 @@ namespace Gecode { namespace Set { friend class LubRanges; friend class GlbRanges; friend bool Gecode::Set::operator==(const Gecode::Set::ConstSetView&, const Gecode::Set::ConstSetView&); - friend bool Gecode::Set::operator!=(const Gecode::Set::ConstSetView&, const Gecode::Set::ConstSetView&); private: int* ranges; @@ -319,9 +317,6 @@ namespace Gecode { namespace Set { /// Test whether views \a x and \a y are the same /// \relates Gecode::Set::ConstSetView bool operator==(const ConstSetView& x, const ConstSetView& y); - /// Test whether views \a x and \a y are not the same - /// \relates Gecode::Set::ConstSetView - bool operator!=(const ConstSetView& x, const ConstSetView& y); //@} /** @@ -445,9 +440,6 @@ namespace Gecode { namespace Set { /// Test whether views \a x and \a y are the same /// \relates Gecode::Set::EmptyView bool operator==(const EmptyView& x, const EmptyView& y); - /// Test whether views \a x and \a y are the same - /// \relates Gecode::Set::EmptyView - bool operator!=(const EmptyView& x, const EmptyView& y); //@} /** @@ -572,9 +564,6 @@ namespace Gecode { namespace Set { /// Test whether views \a x and \a y are the same /// \relates Gecode::Set::UniverseView bool operator==(const UniverseView& x, const UniverseView& y); - /// Test whether views \a x and \a y are the not same - /// \relates Gecode::Set::UniverseView - bool operator!=(const UniverseView& x, const UniverseView& y); //@} /** @@ -745,9 +734,6 @@ namespace Gecode { namespace Set { /// Test whether views \a x and \a y are the same /// \relates Gecode::Set::SingletonView bool operator==(const SingletonView& x, const SingletonView& y); - /// Test whether views \a x and \a y are the not same - /// \relates Gecode::Set::SingletonView - bool operator!=(const SingletonView& x, const SingletonView& y); //@} /** @@ -915,10 +901,6 @@ namespace Gecode { namespace Set { /// \relates Gecode::Set::ComplementView template bool operator==(const ComplementView& x, const ComplementView& y); - /// Test whether views \a x and \a y are the not same - /// \relates Gecode::Set::ComplementView - template - bool operator!=(const ComplementView& x, const ComplementView& y); //@} template @@ -1116,10 +1098,6 @@ namespace Gecode { namespace Set { /// \relates Gecode::Set::CachedView template bool operator==(const CachedView& x, const CachedView& y); - /// Test whether views \a x and \a y are the not same - /// \relates Gecode::Set::CachedView - template - bool operator!=(const CachedView& x, const CachedView& y); //@} /** diff --git a/gecode/set/view/cached.hpp b/gecode/set/view/cached.hpp index 4af0b822e3..77790c596c 100644 --- a/gecode/set/view/cached.hpp +++ b/gecode/set/view/cached.hpp @@ -381,12 +381,6 @@ namespace Gecode { namespace Set { return x.base() == y.base(); } - template - forceinline bool - operator!=(const CachedView& x, const CachedView& y) { - return x.base() != y.base(); - } - template forceinline GlbDiffRanges::GlbDiffRanges(const CachedView& x) diff --git a/gecode/set/view/complement.hpp b/gecode/set/view/complement.hpp index 3f441bfafa..c29fce2a26 100644 --- a/gecode/set/view/complement.hpp +++ b/gecode/set/view/complement.hpp @@ -579,12 +579,6 @@ namespace Gecode { namespace Set { return x.base() == y.base(); } - template - forceinline bool - operator!=(const ComplementView& x, const ComplementView& y) { - return x.base() != y.base(); - } - }} // namespace Gecode::Set // STATISTICS: set-var diff --git a/gecode/set/view/const.hpp b/gecode/set/view/const.hpp index 9fe97289be..54c447e7b1 100644 --- a/gecode/set/view/const.hpp +++ b/gecode/set/view/const.hpp @@ -813,33 +813,21 @@ namespace Gecode { namespace Set { operator==(const ConstSetView& x, const ConstSetView& y) { if ((x.size != y.size) || (x.dom_size != y.dom_size)) return false; - for (int i = x.size; i--;) + for (int i = 0; i < x.size; i++) if ((x.ranges[2 * i] != y.ranges[2 * i]) || (x.ranges[2 * i + 1] != y.ranges[2 * i + 1])) return false; return true; } - forceinline bool - operator!=(const ConstSetView& x, const ConstSetView& y) { - return !(x == y); - } forceinline bool operator==(const EmptyView&, const EmptyView&) { return true; } - forceinline bool - operator!=(const EmptyView&, const EmptyView&) { - return false; - } forceinline bool operator==(const UniverseView&, const UniverseView&) { return true; } - forceinline bool - operator!=(const UniverseView&, const UniverseView&) { - return false; - } }} // namespace Gecode::Set diff --git a/gecode/set/view/singleton.hpp b/gecode/set/view/singleton.hpp index 06371c5fb6..e2d425d845 100644 --- a/gecode/set/view/singleton.hpp +++ b/gecode/set/view/singleton.hpp @@ -319,11 +319,6 @@ namespace Gecode { namespace Set { return x.base() == y.base(); } - forceinline bool - operator!=(const SingletonView& x, const SingletonView& y) { - return x.base() != y.base(); - } - /* * Iterators * diff --git a/gecode/support/bitset-base.hpp b/gecode/support/bitset-base.hpp index b9029c0530..117e0e6c1c 100644 --- a/gecode/support/bitset-base.hpp +++ b/gecode/support/bitset-base.hpp @@ -101,10 +101,8 @@ namespace Gecode { namespace Support { void o(BitSetData a, unsigned int i); /// Return "or" of \a a and \a b static BitSetData o(BitSetData a, BitSetData b); - /// Check if bits are the same as for \a a - bool operator==(BitSetData a) const; - /// Check if bits are not the same as for \a a - bool operator!=(BitSetData a) const; + /// Whether both hold the same bits + bool operator==(const BitSetData&) const = default; /// Invert all bits in \a b BitSetData operator~(void) const; }; @@ -323,14 +321,6 @@ namespace Gecode { namespace Support { iv.bits = ~bits; return iv; } - forceinline bool - BitSetData::operator==(BitSetData a) const { - return bits == a.bits; - } - forceinline bool - BitSetData::operator!=(BitSetData a) const { - return bits != a.bits; - } /* * Basic bit sets diff --git a/test/float/basic.cpp b/test/float/basic.cpp index 36d2c21ac6..174735079b 100644 --- a/test/float/basic.cpp +++ b/test/float/basic.cpp @@ -174,9 +174,47 @@ namespace Test { namespace Float { } }; + /// Test comparing float views + class ViewCompare : public Base { + private: + /// Space for the variables behind the views + class Fixture : public Gecode::Space { + public: + Fixture(void) = default; + // NOLINTNEXTLINE(modernize-use-equals-default) + Fixture(Fixture& fixture) : Gecode::Space(fixture) {} + Gecode::Space* + copy(void) override { + return new Fixture(*this); + } + }; + + public: + /// Create and register test + ViewCompare(void) : Base("Float::Basic::View::Compare") {} + /// Perform test + bool + run(void) override { + using namespace Gecode; + using namespace Gecode::Float; + Fixture home; + FloatView x(FloatVar(home, 0.0, 1.0)); + FloatView y(FloatVar(home, 0.0, 1.0)); + MinusView mx(x); + return compares_equal(mx, MinusView(x)) && compares_unequal(mx, MinusView(y)) && + compares_equal(OffsetView(x, 1.0), OffsetView(x, 1.0)) && + compares_unequal(OffsetView(x, 1.0), OffsetView(x, 2.0)) && + compares_unequal(OffsetView(x, 1.0), OffsetView(y, 1.0)) && + compares_equal(ScaleView(2.0, x), ScaleView(2.0, x)) && + compares_unequal(ScaleView(2.0, x), ScaleView(3.0, x)) && + compares_unequal(ScaleView(2.0, x), ScaleView(2.0, y)) && compares_unequal(x, mx); + } + }; + namespace { OptimizeCut optimize_cut; - } + ViewCompare view_compare; + } // namespace //@} } // namespace Basic diff --git a/test/groups.cpp b/test/groups.cpp index 00b5780798..509dbbf7a8 100644 --- a/test/groups.cpp +++ b/test/groups.cpp @@ -106,6 +106,27 @@ namespace Test { namespace Groups { } }; + /// %Test for comparing propagator and brancher groups + class Compare : public Test::Base { + public: + /// Initialize test + Compare(void) : Test::Base("Group::Compare") {} + /// Perform actual tests + bool + run(void) override { + using namespace Gecode; + PropagatorGroup p, q; + PropagatorGroup p_copy(p); + BrancherGroup b, c; + BrancherGroup b_copy(b); + return compares_equal(p, p_copy) && compares_unequal(p, q) && + compares_unequal(PropagatorGroup::all, PropagatorGroup::def) && compares_equal(b, b_copy) && + compares_unequal(b, c) && compares_unequal(BrancherGroup::all, BrancherGroup::def); + } + }; + + Compare compare; + /// Help class to create and register tests class Create { public: diff --git a/test/int/basic.cpp b/test/int/basic.cpp index d44dc77b94..0d4c4d013f 100644 --- a/test/int/basic.cpp +++ b/test/int/basic.cpp @@ -69,6 +69,74 @@ namespace Test { namespace Int { Gecode::IntArgs i({1, 2, 3, 4}); Basic b1(3); Basic b2(i); + + /// %Test for comparing integer sets + class IntSetCompare : public Base { + public: + /// Create and register test + IntSetCompare(void) : Base("Int::Basic::IntSet::Compare") {} + /// Perform test + bool + run(void) override { + using namespace Gecode; + IntSet s({1, 3, 5}); + IntSet same({1, 3, 5}); + IntSet other(1, 5); + IntSet s_copy(s); + return compares_equal(s, same) && compares_equal(s, s_copy) && compares_unequal(s, other) && + compares_equal(IntSet::empty, IntSet(1, 0)) && compares_unequal(s, IntSet::empty); + } + }; + + IntSetCompare int_set_compare; + + /// %Test for comparing integer and Boolean views + class ViewCompare : public Base { + private: + /// Space for the variables behind the views + class Fixture : public Gecode::Space { + public: + Fixture(void) = default; + // NOLINTNEXTLINE(modernize-use-equals-default) + Fixture(Fixture& fixture) : Gecode::Space(fixture) {} + Gecode::Space* + copy(void) override { + return new Fixture(*this); + } + }; + + public: + /// Create and register test + ViewCompare(void) : Base("Int::Basic::View::Compare") {} + /// Perform test + bool + run(void) override { + using namespace Gecode; + using namespace Gecode::Int; + Fixture home; + IntView x(IntVar(home, 0, 5)); + IntView y(IntVar(home, 0, 5)); + BoolView b(BoolVar(home, 0, 1)); + BoolView c(BoolVar(home, 0, 1)); + MinusView mx(x); + return compares_equal(mx, MinusView(x)) && compares_unequal(mx, MinusView(y)) && + compares_equal(OffsetView(x, 2), OffsetView(x, 2)) && + compares_unequal(OffsetView(x, 2), OffsetView(x, 3)) && + compares_unequal(OffsetView(x, 2), OffsetView(y, 2)) && + compares_equal(IntScaleView(2, x), IntScaleView(2, x)) && + compares_unequal(IntScaleView(2, x), IntScaleView(3, x)) && + compares_unequal(IntScaleView(2, x), IntScaleView(2, y)) && + compares_equal(ConstIntView(4), ConstIntView(4)) && + compares_unequal(ConstIntView(4), ConstIntView(5)) && + compares_equal(ZeroIntView(), ZeroIntView()) && + compares_equal(CachedView(x), CachedView(x)) && + compares_unequal(CachedView(x), CachedView(y)) && + compares_equal(NegBoolView(b), NegBoolView(b)) && + compares_unequal(NegBoolView(b), NegBoolView(c)) && compares_unequal(x, mx); + } + }; + + ViewCompare view_compare; //@} } // namespace Basic diff --git a/test/int/bin-packing.cpp b/test/int/bin-packing.cpp index 0cbbe3a133..dbad6d8373 100644 --- a/test/int/bin-packing.cpp +++ b/test/int/bin-packing.cpp @@ -32,6 +32,7 @@ #include "test/int.hh" +#include #include #include @@ -402,6 +403,39 @@ namespace Test { namespace Int { Empty empty; + /// %Test for comparing bin-packing items + class ItemCompare : public Base { + private: + /// Space for the bin variables + class Fixture : public Gecode::Space { + public: + Fixture(void) = default; + // NOLINTNEXTLINE(modernize-use-equals-default) + Fixture(Fixture& fixture) : Gecode::Space(fixture) {} + Gecode::Space* + copy(void) override { + return new Fixture(*this); + } + }; + + public: + ItemCompare(void) : Base("Int::BinPacking::Item::Compare") {} + bool + run(void) override { + using namespace Gecode; + using Gecode::Int::BinPacking::Item; + Fixture home; + Gecode::Int::IntView b(IntVar(home, 0, 3)); + Gecode::Int::IntView c(IntVar(home, 0, 3)); + const Item i(b, 2); + const Item i_copy(i); + return compares_equal(i, i_copy) && compares_equal(i, Item(b, 2)) && compares_unequal(i, Item(b, 3)) && + compares_unequal(i, Item(c, 2)); + } + }; + + ItemCompare item_compare; + /// Large weights must preserve every feasible bin assignment. class DFFLargeWeights : public Test { int capacity; diff --git a/test/int/extensional.cpp b/test/int/extensional.cpp index 8c23cd73e0..2878343c39 100644 --- a/test/int/extensional.cpp +++ b/test/int/extensional.cpp @@ -827,6 +827,25 @@ namespace Test { namespace Int { } }; + /// %Test for comparing DFAs + class DFACompare : public ::Test::Base { + public: + DFACompare(void) : ::Test::Base("Int::Extensional::DFA::Compare") {} + + bool + run(void) override { + using namespace Gecode; + DFA d(REG(0) + REG(1)); + DFA same(REG(0) + REG(1)); + DFA other(REG(1) + REG(0)); + // NOLINTNEXTLINE(performance-unnecessary-copy-initialization) + DFA d_copy(d); + DFA empty, other_empty; + return compares_equal(d, same) && compares_equal(d, d_copy) && compares_unequal(d, other) && + compares_equal(empty, other_empty) && compares_unequal(d, empty); + } + }; + /// Space used by open regular tests class OpenRegularSpace : public Gecode::Space { public: @@ -1675,6 +1694,46 @@ namespace Test { namespace Int { } }; + /// %Test for comparing finalized tuple sets + class TupleSetCompare : public ::Test::Base { + public: + TupleSetCompare(void) : ::Test::Base("Int::Extensional::TupleSet::Compare") {} + + bool + run(void) override { + using namespace Gecode; + TupleSet t(2), same(2), other(2); + t.add(IntArgs({0, 1})).add(IntArgs({1, 0})).finalize(); + same.add(IntArgs({0, 1})).add(IntArgs({1, 0})).finalize(); + other.add(IntArgs({0, 1})).finalize(); + TupleSet t_copy(t); + if (!compares_equal(t, same) || !compares_equal(t, t_copy) || !compares_unequal(t, other)) + return false; + // A bool on the left compares with the tuple set's bool + // conversion; TupleSet::operator!= keeps these unambiguous. + return (true == t) && !(true != t); + } + }; + + /// %Test for comparing the bit-set words that tuple-set supports use + class BitSetDataCompare : public ::Test::Base { + public: + BitSetDataCompare(void) : ::Test::Base("Int::Extensional::BitSetData::Compare") {} + + bool + run(void) override { + using Gecode::Support::BitSetData; + BitSetData b, other; + b.init(false); + other.init(false); + BitSetData b_copy(b); + if (!compares_equal(b, other) || !compares_equal(b, b_copy)) + return false; + other.set(3); + return compares_unequal(b, other); + } + }; + /// Disabled compact propagators preserve pending work when cloned class TupleSetDisabledClone : public ::Test::Base { public: @@ -2400,6 +2459,7 @@ namespace Test { namespace Int { OpenRegularEmpty open_regular_empty_reject(OpenRegularEmpty::Kind::REJECT); OpenRegularEmpty open_regular_no_finals(OpenRegularEmpty::Kind::NO_FINALS); OpenRegularClosed open_regular_closed; + DFACompare dfa_compare; /// Exhaustive positive, negative, and reified sparse-table semantics. class CreateSparse { @@ -2446,6 +2506,8 @@ namespace Test { namespace Int { TupleSetSupportOffsetBoundary tuple_set_support_offset_boundary; TupleSetTerminalFinalizationFailure tuple_set_terminal_failure; TupleSetDFARepresentation tuple_set_dfa_representation; + TupleSetCompare tuple_set_compare; + BitSetDataCompare bit_set_data_compare; TupleSetDisabledClone tuple_set_disabled_clone; TupleSetAutoDefaultDispatch tuple_set_auto_default_dispatch; DenseCompressedTupleSetWideGap dense_compressed_tuple_set_wide_gap; diff --git a/test/ldsb.cpp b/test/ldsb.cpp index 590f28ff4c..29feaaf09f 100644 --- a/test/ldsb.cpp +++ b/test/ldsb.cpp @@ -33,6 +33,7 @@ #include #include #include +#include #ifdef GECODE_HAS_SET_VARS #include @@ -44,6 +45,7 @@ #include "test/test.hh" +#include #include /** @@ -1858,6 +1860,23 @@ namespace Test { namespace LDSB { } }; + /// %Test that literals order by variable index, then by value + class LiteralCompare : public Base { + public: + /// Initialize test + LiteralCompare(void) : Base("LDSB::Literal::Compare") {} + /// Perform actual tests + bool + run(void) override { + using Gecode::Int::LDSB::Literal; + const Literal l(0, 1); + const Literal l_copy(l); + return compares_equal(l, l_copy) && compares_unequal(l, Literal(0, 2)) && (l < Literal(0, 2)) && + !(Literal(0, 2) < l) && !(l < l_copy) && (Literal(0, 5) < Literal(1, 0)) && + (Literal() < Literal(0, 0)) && ((l <=> Literal(1, 0)) == std::strong_ordering::less); + } + }; + #ifdef GECODE_HAS_SET_VARS /// %Test that set LDSB branching ignores symmetries without variables or values class EmptySet : public Base { @@ -1922,6 +1941,7 @@ namespace Test { namespace LDSB { LDSB tie_break("TieBreak"); EmptyInt empty_int; EmptyBool empty_bool; + LiteralCompare literal_compare; #ifdef GECODE_HAS_SET_VARS LDSB reflectsym1("ReflectSym1"); diff --git a/test/region.cpp b/test/region.cpp index 94153ade6a..13b168dc13 100644 --- a/test/region.cpp +++ b/test/region.cpp @@ -64,24 +64,23 @@ namespace Test { Region r; + /// Space without variables + class EmptySpace : public Gecode::Space { + public: + /// Initialize space + EmptySpace(void) = default; + /// Constructor for cloning \a s + // NOLINTNEXTLINE(modernize-use-equals-default) + EmptySpace(EmptySpace& s) : Gecode::Space(s) {} + /// Copy space during cloning + Gecode::Space* + copy(void) override { + return new EmptySpace(*this); + } + }; + /// %Test for growing space memory from an empty block class SpaceReallocEmpty : public Test::Base { - private: - /// Space without variables - class EmptySpace : public Gecode::Space { - public: - /// Initialize space - EmptySpace(void) = default; - /// Constructor for cloning \a s - // NOLINTNEXTLINE(modernize-use-equals-default) - EmptySpace(EmptySpace& s) : Gecode::Space(s) {} - /// Copy space during cloning - Gecode::Space* - copy(void) override { - return new EmptySpace(*this); - } - }; - public: /// Initialize test SpaceReallocEmpty(void) : Test::Base("Space::Realloc::Empty") {} @@ -100,6 +99,30 @@ namespace Test { SpaceReallocEmpty space_realloc_empty; + /// %Test for comparing space and region allocators + class AllocatorCompare : public Test::Base { + public: + /// Initialize test + AllocatorCompare(void) : Test::Base("Allocator::Compare") {} + /// Perform actual tests + bool + run(void) override { + using namespace Gecode; + EmptySpace home, other_home; + const space_allocator space_alloc(home); + Gecode::Region region, other_region; + const region_allocator region_alloc(region); + return compares_equal(space_alloc, space_allocator(home)) && + compares_unequal(space_alloc, space_allocator(other_home)) && + compares_equal(space_alloc, space_allocator(space_alloc)) && + compares_equal(region_alloc, region_allocator(region)) && + compares_unequal(region_alloc, region_allocator(other_region)) && + compares_equal(region_alloc, region_allocator(region_alloc)); + } + }; + + AllocatorCompare allocator_compare; + /// %Test for copying and assigning empty archives class ArchiveEmpty : public Test::Base { public: diff --git a/test/set/construct.cpp b/test/set/construct.cpp index f40d252eba..2debeb20d6 100644 --- a/test/set/construct.cpp +++ b/test/set/construct.cpp @@ -206,6 +206,49 @@ namespace Test { namespace Set { }; Construct _con; + /// %Test for comparing set views + class ViewCompare : public ::Test::Base { + private: + /// Space for the variables behind the views + class Fixture : public Gecode::Space { + public: + Fixture(void) = default; + // NOLINTNEXTLINE(modernize-use-equals-default) + Fixture(Fixture& fixture) : Gecode::Space(fixture) {} + Gecode::Space* + copy(void) override { + return new Fixture(*this); + } + }; + + public: + /// Create and register test + ViewCompare(void) : ::Test::Base("Set::Var::View::Compare") {} + /// Perform test + bool + run(void) override { + using namespace Gecode::Set; + Fixture home; + SetView x(SetVar(home, IntSet::empty, 0, 5)); + SetView y(SetVar(home, IntSet::empty, 0, 5)); + IntVar i(home, 0, 5); + IntVar j(home, 0, 5); + ConstSetView c(home, IntSet(1, 3)); + ComplementView cx(x); + ComplementView cy(y); + return compares_equal(c, ConstSetView(home, IntSet(1, 3))) && + compares_unequal(c, ConstSetView(home, IntSet(1, 4))) && + compares_equal(EmptyView(), EmptyView()) && compares_equal(UniverseView(), UniverseView()) && + compares_equal(SingletonView(i), SingletonView(i)) && + compares_unequal(SingletonView(i), SingletonView(j)) && + compares_equal(cx, ComplementView(x)) && compares_unequal(cx, cy) && + compares_equal(CachedView(x), CachedView(x)) && + compares_unequal(CachedView(x), CachedView(y)); + } + }; + + ViewCompare view_compare; + } // namespace Var }} // namespace Test::Set diff --git a/test/test.hh b/test/test.hh index 865c7c5305..aded89b89f 100644 --- a/test/test.hh +++ b/test/test.hh @@ -234,6 +234,16 @@ namespace Test { static std::string str(const Gecode::IntArgs& i); //@} + /// \name Checking comparison operators + //@{ + /// Whether \a x and \a y are equal by == and != in both argument orders + template + static bool compares_equal(const T1& x, const T2& y); + /// Whether \a x and \a y are unequal by == and != in both argument orders + template + static bool compares_unequal(const T1& x, const T2& y); + //@} + /// Random number generator mutable Gecode::Support::RandomGenerator _rand; }; diff --git a/test/test.hpp b/test/test.hpp index 282b42cdee..5643d86cc5 100644 --- a/test/test.hpp +++ b/test/test.hpp @@ -133,6 +133,18 @@ namespace Test { return "[" + s + str(x[x.size() - 1]) + "]"; } + template + inline bool + Base::compares_equal(const T1& x, const T2& y) { + return (x == y) && (y == x) && !(x != y) && !(y != x); + } + + template + inline bool + Base::compares_unequal(const T1& x, const T2& y) { + return !(x == y) && !(y == x) && (x != y) && (y != x); + } + } // namespace Test // STATISTICS: test-core From 49a08cf3a5bef25ae69a9c9fb25e14ecee27c73f Mon Sep 17 00:00:00 2001 From: Mikael Zayenz Lagerkvist Date: Wed, 4 Nov 2026 06:48:52 +0100 Subject: [PATCH 4/4] State when to merge overload pairs with deducing this docs/code-style.md now says when a const/non-const pair becomes one explicit-object member: when it removes a duplicated multi-statement body or a const_cast forwarding idiom, and only if every receiver keeps its return type and still compiles. Matrix::operator(), the inventory's one candidate, keeps its pair: the merged template would reach Matrix's members through the derived receiver, so a privately derived matrix that re-exports the operator with using would stop compiling. No code changes. Zdev-Change-Id: Zc91a9af7d8acb308ae558783a8e4cdbc02beb31aab8135136c8ea1701ebf7986 --- docs/code-style.md | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/docs/code-style.md b/docs/code-style.md index 156897d9f8..50989b51d2 100644 --- a/docs/code-style.md +++ b/docs/code-style.md @@ -185,6 +185,26 @@ operator keeps `operator!=` as well. `TupleSet` is one: without its covers only operator expressions, so write `a != b`, not `operator!=(a, b)` or `a.operator<(b)`. No clang-tidy check enforces this rule. +A const/non-const overload pair stays a pair unless one member with an +explicit object parameter, `template auto& f(this Self&& self)`, +removes a duplicated body of more than one statement, not counting `assert`, +or a `const_cast` forwarding idiom. A pair whose bodies are one statement each +stays: the merged template is not shorter. Merge only when the merged member +returns the same type and accepts the same receivers as the pair, including +rvalues and calls through derived classes. A member reached through `self` +is looked up in the receiver's class, so a derived class can hide it, and a +class that inherits privately and re-exports the member with `using` makes +the base inaccessible, so the call no longer compiles. Storage reached +through a pointer does not inherit const from `self`; return it through +`std::forward_like`. An explicit-object member cannot be virtual or +static, takes no trailing cv or ref qualifier, and its address is a plain +function pointer rather than a member pointer. The merged member is a +template over `Self`, so its definition must be visible to callers: a pair +defined in a .cpp file moves to a header. `Matrix::operator()` keeps its pair +for the derived-class reason: its two bodies duplicate a range check, but a +merged member would reject a privately derived matrix. No clang-tidy check +enforces this rule. + Other performance checks need focused review: `performance-enum-size` changes layouts and ABI, and `performance-no-int-to-ptr` conflicts with deliberate pointer tagging. Review `noexcept` guarantees, destructor triviality, and math