vendredi 3 novembre 2023

Why do I get a -Wdeprecated-copy on this class? [closed]

Here's my code for define a CTOR copy of class ClassAValveParameters (taken from an online library):

// hpp
ClassAValveParameters &operator=(const ClassAValveParameters &params);

// cpp
ClassAValveParameters &ClassAValveParameters::operator=(const ClassAValveParameters &params) {
    // --- it is possible to try to make the object equal to itself
    //     e.g. thisObject = thisObject; so this code catches that
    //     trivial case and just returns this object
    if (this == &params)
        return *this;

    // --- copy from params (argument) INTO our variables
    lowFrequencyShelf_Hz = params.lowFrequencyShelf_Hz;
    lowFrequencyShelfGain_dB = params.lowFrequencyShelfGain_dB;
    dcBlockingLF_Hz = params.dcBlockingLF_Hz;
    millerHF_Hz = params.millerHF_Hz;
    clipPointPositive = params.clipPointPositive;
    clipPointNegative = params.clipPointNegative;
    dcShiftCoefficient = params.dcShiftCoefficient;
    dcOffsetDetected = params.dcOffsetDetected;
    gridConductionThreshold = params.gridConductionThreshold;
    waveshaperSaturation = params.waveshaperSaturation;
    dcOffsetDetected = params.dcOffsetDetected;
    inputGain = params.inputGain;
    outputGain = params.outputGain;
    integratorFc = params.integratorFc;

    // --- MUST be last
    return *this;
}

But on C++11, it says warning: implicitly-declared 'constexpr ClassAValveParameters::ClassAValveParameters(const ClassAValveParameters&)' is deprecated [-Wdeprecated-copy], and I don't get why (and how to fix it).

Any clues?

Aucun commentaire:

Enregistrer un commentaire