Skip to content

Commit

Permalink
Fix GCC build errors in PCA example (#3037)
Browse files Browse the repository at this point in the history
Add missing copy constructor or assignment operators to fix GCC "implicitly-declared operator= is deprecated" and similar errors triggered by `-Werror=deprecated-copy` compiler option in `pca_cor_dense_batch` example.
  • Loading branch information
Vika-F authored Jan 10, 2025
1 parent a64b115 commit 0f70b05
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 3 deletions.
14 changes: 11 additions & 3 deletions cpp/daal/include/algorithms/algorithm_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -219,11 +219,17 @@ class DAAL_EXPORT Argument

protected:
/**
* Copy constructor
* \param[in] other Instance of the same class to copy
*/
* Copy constructor
* \param[in] other Instance of the same class to copy
*/
Argument(const Argument & other);

/**
* Copy assignment operator
* \param[in] other Instance of the same class to copy
*/
Argument & operator=(const Argument & other);

/**
* Retrieves specified element
* \param[in] index Index of the element
Expand Down Expand Up @@ -326,6 +332,8 @@ class Input : public Argument
* \param[in] other Instance of the same class to copy
*/
Input(const Input & other) : Argument(other) {}

Input & operator=(const Input & other) = default;
};

/**
Expand Down
14 changes: 14 additions & 0 deletions cpp/daal/include/data_management/data/data_dictionary.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,25 @@ class NumericTableFeature : public SerializationIface
categoryNumber = 0;
}

/**
* Copy constructor for a data feature
*/
NumericTableFeature(const NumericTableFeature & f)
{
indexType = f.indexType;
pmmlType = f.pmmlType;
featureType = f.featureType;
typeSize = f.typeSize;
categoryNumber = f.categoryNumber;
}

/**
* Copy operator for a data feature
*/
NumericTableFeature & operator=(const NumericTableFeature & f)
{
if (this == &f) return *this;

indexType = f.indexType;
pmmlType = f.pmmlType;
featureType = f.featureType;
Expand Down
8 changes: 8 additions & 0 deletions cpp/daal/src/algorithms/algorithm_base_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,14 @@ algorithms::Argument::Argument(const algorithms::Argument & other)
: _storage(new internal::ArgumentStorage(*(internal::ArgumentStorage *)other._storage.get())), idx(0)
{}

algorithms::Argument & algorithms::Argument::operator=(const algorithms::Argument & other)
{
if (this == &other) return *this;
_storage = data_management::DataCollectionPtr(new internal::ArgumentStorage(*(internal::ArgumentStorage *)other._storage.get()));
idx = 0;
return *this;
}

const data_management::SerializationIfacePtr & algorithms::Argument::get(size_t index) const
{
return (*_storage)[index];
Expand Down

0 comments on commit 0f70b05

Please sign in to comment.