From bf6532a69daed18cdaa74060912caf4de9e2d423 Mon Sep 17 00:00:00 2001 From: Ichthyostega Date: Tue, 15 Apr 2025 18:32:52 +0200 Subject: [PATCH] Upgrade: address warnings -- deprecated implicit copy MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Future C++ versions will no longer generate default copy operations once any single one was defined explicitly. So the goal is to kind-of ''enforce the rule of five'' (if you define one, define them all). However, sometimes one of these special operators must be defined for a different reason, e.g. because it is defined as protected, yet should not be exposed on the public API. In such cases, any other copy operation which still is valid in the default form must be declared explicitly ''as defaulted'' Overall this seems to be quite an improvement -- and it highlights (again) some known instances of questionable design, which are mostly obsoleted and require clean-up anyway, or (as in the case of the Placements) indicate »placeholder code« where the actual solution still needs to be worked out --- src/lib/symbol.hpp | 5 ++--- src/lib/time/timevalue.hpp | 18 +++++++++++------- src/steam/engine/buffer-local-tag.hpp | 2 ++ src/steam/mobject/explicitplacement.hpp | 17 ++++++++++++----- src/steam/mobject/placement.hpp | 5 +++++ .../steam/control/command-argument-test.cpp | 4 +++- tests/library/replaceable-item-test.cpp | 2 ++ 7 files changed, 37 insertions(+), 16 deletions(-) diff --git a/src/lib/symbol.hpp b/src/lib/symbol.hpp index acfca01cd..b494e3f0c 100644 --- a/src/lib/symbol.hpp +++ b/src/lib/symbol.hpp @@ -85,9 +85,8 @@ namespace lib { : str_(literal) { } - Literal (Literal const& o) noexcept - : str_(o.str_) - { } + Literal (Literal const&) noexcept = default; + Literal& operator= (Literal const&) noexcept = default; operator CStr() const { return str_; } const char* c() const { return str_; } diff --git a/src/lib/time/timevalue.hpp b/src/lib/time/timevalue.hpp index 5e2f380b1..289cf4b6a 100644 --- a/src/lib/time/timevalue.hpp +++ b/src/lib/time/timevalue.hpp @@ -250,10 +250,10 @@ namespace time { : TimeValue(o) { } - TimeVar& - operator= (TimeValue const& o) + TimeVar& operator= (TimeVar const&) = default; + TimeVar& operator= (TimeValue const& o) { - t_ = TimeVar(o); + *this = TimeVar(o); return *this; } @@ -318,13 +318,15 @@ namespace time { : TimeValue(val) { } + explicit + Time (FSecs const& fractionalSeconds); + + Time (Time const&) = default; + Time (TimeVar const& calcResult) : TimeValue(calcResult) { } - explicit - Time (FSecs const& fractionalSeconds); - Time ( long millis , uint secs , uint mins =0 @@ -375,7 +377,9 @@ namespace time { explicit Offset (FSecs const& delta_in_secs); - + + Offset (Offset const&) = default; + Offset (FrameCnt count, FrameRate const& fps); Offset (TimeValue const& origin, TimeValue const& target) diff --git a/src/steam/engine/buffer-local-tag.hpp b/src/steam/engine/buffer-local-tag.hpp index 0486e6052..67d41d9c3 100644 --- a/src/steam/engine/buffer-local-tag.hpp +++ b/src/steam/engine/buffer-local-tag.hpp @@ -69,6 +69,8 @@ namespace engine { privateID_._as_pointer = impl_related_ptr; } + LocalTag (LocalTag const&) = default; + /** Marker when no distinct local key is given */ static const LocalTag UNKNOWN; diff --git a/src/steam/mobject/explicitplacement.hpp b/src/steam/mobject/explicitplacement.hpp index 4de25d6e3..20874a29c 100644 --- a/src/steam/mobject/explicitplacement.hpp +++ b/src/steam/mobject/explicitplacement.hpp @@ -47,6 +47,10 @@ namespace mobject { * and reduced to simple positions. This so called Fixture * contains only ExplicitPlacement objects and is processed * by the Builder to create the render engine node network. + * + * @deprecated 2025/4 while we need a marker for an _explicit placement,_ + * implementing this as a subclass is the dog-no-wag-tail anti pattern. + * Inheritance indicates a contract, but should not be abused to mark properties. * * @ingroup fixture * @see Placement#resolve factory method for deriving an ExplicitPlacement @@ -57,7 +61,7 @@ namespace mobject { const Time time; const Pipe pipe; - typedef std::pair SolutionData; //TODO (ichthyo considers better passing of solution by subclass) + typedef std::pair SolutionData; //////////////////////TICKET #100 : ichthyo considers better passing of solution by subclass... /** no need to resolve any further, as this ExplicitPlacement * already \e is the result of a resolve()-call. @@ -66,7 +70,7 @@ namespace mobject { virtual ExplicitPlacement resolve () const { - return *this; + return *this; // and this very special dog breaks the wag-the-tail contract :-P } @@ -75,13 +79,16 @@ namespace mobject { * of FixedLocation, which would serve as Placement::LocatingSolution, and * would be used as LocatingPin::chain subobject as well, so that it could * be initialised directly here in the ExplicitPlacement ctor. - * (ichthyo: see Trac #100) + * /////////////////////////////////////////////////////////TICKET #100 */ - ExplicitPlacement (const Placement& base, const SolutionData found) + ExplicitPlacement (Placement const& base, const SolutionData found) : Placement(base), time(found.first), pipe(found.second) { }; - + + /** @warning 2025/4 design smells all over the place. It should not be copyable!! */ + ExplicitPlacement (ExplicitPlacement const&) = default; + friend ExplicitPlacement Placement::resolve () const; private: diff --git a/src/steam/mobject/placement.hpp b/src/steam/mobject/placement.hpp index fdad618c2..d04590668 100644 --- a/src/steam/mobject/placement.hpp +++ b/src/steam/mobject/placement.hpp @@ -197,6 +197,11 @@ namespace mobject { , chain(ref.chain) { } + /** @todo 2025-4 what is the semantics of such an assignment? + * Shouldn't placement be treated with reference semantics? //////////////////////////////////TICKET #123 : (from 2009) "Find out about the correct meaning when assigning placements...." + */ + Placement& operator= (Placement const&) = default; + protected: Placement (MObject & subject, Deleter killer) : _SmartPtr (&subject, killer) { }; diff --git a/tests/core/steam/control/command-argument-test.cpp b/tests/core/steam/control/command-argument-test.cpp index f2d88e3b4..07af7f721 100644 --- a/tests/core/steam/control/command-argument-test.cpp +++ b/tests/core/steam/control/command-argument-test.cpp @@ -72,7 +72,9 @@ namespace test { Tracker (TY init = TY()) : element_(init) { ++instanceCnt; } Tracker (Tracker const& otr) : element_(otr.element_) { ++instanceCnt; } ~Tracker() { --instanceCnt; } - + + Tracker& operator= (Tracker const&) = default; + TY& operator* () { diff --git a/tests/library/replaceable-item-test.cpp b/tests/library/replaceable-item-test.cpp index b361fa2ae..3bb518663 100644 --- a/tests/library/replaceable-item-test.cpp +++ b/tests/library/replaceable-item-test.cpp @@ -51,6 +51,8 @@ namespace test{ Tracker(Tracker const& ot) : i_(ot.i_) { ++cntTracker; } Tracker(uint i) : i_(i) { ++cntTracker; } ~Tracker() { --cntTracker; } + + Tracker& operator= (Tracker const&) = default; }; struct NonAssign