mirror of
https://gitlab.com/libeigen/eigen.git
synced 2026-04-10 11:34:33 +08:00
Bug #1788: Fix rule-of-three violations inside the stable modules.
This fixes deprecated-copy warnings when compiling with GCC>=9
Also protect some additional Base-constructors from getting called by user code code (#1587)
Cherry-picked from 870e53c0
This commit is contained in:
@@ -850,11 +850,48 @@ namespace Eigen {
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
* \internal
|
||||
* \brief Macro to explicitly define the default copy constructor.
|
||||
* This is necessary, because the implicit definition is deprecated if the copy-assignment is overridden.
|
||||
*/
|
||||
#if EIGEN_HAS_CXX11
|
||||
#define EIGEN_DEFAULT_COPY_CONSTRUCTOR(CLASS) EIGEN_DEVICE_FUNC CLASS(const CLASS&) = default;
|
||||
#else
|
||||
#define EIGEN_DEFAULT_COPY_CONSTRUCTOR(CLASS)
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
/** \internal
|
||||
* \brief Macro to manually inherit assignment operators.
|
||||
* This is necessary, because the implicitly defined assignment operator gets deleted when a custom operator= is defined.
|
||||
* With C++11 or later this also default-implements the copy-constructor
|
||||
*/
|
||||
#define EIGEN_INHERIT_ASSIGNMENT_OPERATORS(Derived) EIGEN_INHERIT_ASSIGNMENT_EQUAL_OPERATOR(Derived)
|
||||
#define EIGEN_INHERIT_ASSIGNMENT_OPERATORS(Derived) \
|
||||
EIGEN_INHERIT_ASSIGNMENT_EQUAL_OPERATOR(Derived) \
|
||||
EIGEN_DEFAULT_COPY_CONSTRUCTOR(Derived)
|
||||
|
||||
/** \internal
|
||||
* \brief Macro to manually define default constructors and destructors.
|
||||
* This is necessary when the copy constructor is re-defined.
|
||||
* For empty helper classes this should usually be protected, to avoid accidentally creating empty objects.
|
||||
*
|
||||
* Hiding the default destructor lead to problems in C++03 mode together with boost::multiprecision
|
||||
*/
|
||||
#if EIGEN_HAS_CXX11
|
||||
#define EIGEN_DEFAULT_EMPTY_CONSTRUCTOR_AND_DESTRUCTOR(Derived) \
|
||||
EIGEN_DEVICE_FUNC Derived() = default; \
|
||||
EIGEN_DEVICE_FUNC ~Derived() = default;
|
||||
#else
|
||||
#define EIGEN_DEFAULT_EMPTY_CONSTRUCTOR_AND_DESTRUCTOR(Derived) \
|
||||
EIGEN_DEVICE_FUNC Derived() {}; \
|
||||
/* EIGEN_DEVICE_FUNC ~Derived() {}; */
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Just a side note. Commenting within defines works only by documenting
|
||||
|
||||
@@ -104,6 +104,9 @@ class no_assignment_operator
|
||||
{
|
||||
private:
|
||||
no_assignment_operator& operator=(const no_assignment_operator&);
|
||||
protected:
|
||||
EIGEN_DEFAULT_COPY_CONSTRUCTOR(no_assignment_operator)
|
||||
EIGEN_DEFAULT_EMPTY_CONSTRUCTOR_AND_DESTRUCTOR(no_assignment_operator)
|
||||
};
|
||||
|
||||
/** \internal return the index type with the largest number of bits */
|
||||
|
||||
Reference in New Issue
Block a user