mirror of
https://gitlab.com/libeigen/eigen.git
synced 2026-04-10 11:34:33 +08:00
Fix rule-of-3 for the Tensor module.
Adds copy constructors to Tensor ops, inherits assignment operators from `TensorBase`. Addresses #1863
This commit is contained in:
committed by
Antonio Sánchez
parent
60218829b7
commit
3669498f5a
@@ -966,6 +966,7 @@ class TensorBase<Derived, ReadOnlyAccessors>
|
||||
template<typename Derived, int AccessLevel = internal::accessors_level<Derived>::value>
|
||||
class TensorBase : public TensorBase<Derived, ReadOnlyAccessors> {
|
||||
public:
|
||||
typedef TensorBase<Derived, ReadOnlyAccessors> Base;
|
||||
typedef internal::traits<Derived> DerivedTraits;
|
||||
typedef typename DerivedTraits::Scalar Scalar;
|
||||
typedef typename DerivedTraits::Index Index;
|
||||
@@ -1146,6 +1147,18 @@ class TensorBase : public TensorBase<Derived, ReadOnlyAccessors> {
|
||||
}
|
||||
|
||||
protected:
|
||||
EIGEN_DEFAULT_EMPTY_CONSTRUCTOR_AND_DESTRUCTOR(TensorBase)
|
||||
EIGEN_DEFAULT_COPY_CONSTRUCTOR(TensorBase)
|
||||
|
||||
template<typename OtherDerived> EIGEN_DEVICE_FUNC
|
||||
EIGEN_STRONG_INLINE Derived& operator=(const OtherDerived& other)
|
||||
{
|
||||
typedef TensorAssignOp<Derived, const OtherDerived> Assign;
|
||||
Assign assign(derived(), other.derived());
|
||||
internal::TensorExecutor<const Assign, DefaultDevice>::run(assign, DefaultDevice());
|
||||
return derived();
|
||||
}
|
||||
|
||||
EIGEN_DEVICE_FUNC
|
||||
EIGEN_STRONG_INLINE Derived& derived() { return *static_cast<Derived*>(this); }
|
||||
EIGEN_DEVICE_FUNC
|
||||
|
||||
Reference in New Issue
Block a user