$darkmode
Eigen  5.0.1-dev
NoAlias.h
1 // This file is part of Eigen, a lightweight C++ template library
2 // for linear algebra.
3 //
4 // Copyright (C) 2009 Gael Guennebaud <gael.guennebaud@inria.fr>
5 //
6 // This Source Code Form is subject to the terms of the Mozilla
7 // Public License v. 2.0. If a copy of the MPL was not distributed
8 // with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 
10 #ifndef EIGEN_NOALIAS_H
11 #define EIGEN_NOALIAS_H
12 
13 // IWYU pragma: private
14 #include "./InternalHeaderCheck.h"
15 
16 namespace Eigen {
17 
33 template <typename ExpressionType, template <typename> class StorageBase>
34 class NoAlias {
35  public:
36  typedef typename ExpressionType::Scalar Scalar;
37 
38  EIGEN_DEVICE_FUNC explicit NoAlias(ExpressionType& expression) : m_expression(expression) {}
39 
40  template <typename OtherDerived>
41  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE ExpressionType& operator=(const StorageBase<OtherDerived>& other) {
42  call_assignment_no_alias(m_expression, other.derived(),
43  internal::assign_op<Scalar, typename OtherDerived::Scalar>());
44  return m_expression;
45  }
46 
47  template <typename OtherDerived>
48  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE ExpressionType& operator+=(const StorageBase<OtherDerived>& other) {
49  call_assignment_no_alias(m_expression, other.derived(),
50  internal::add_assign_op<Scalar, typename OtherDerived::Scalar>());
51  return m_expression;
52  }
53 
54  template <typename OtherDerived>
55  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE ExpressionType& operator-=(const StorageBase<OtherDerived>& other) {
56  call_assignment_no_alias(m_expression, other.derived(),
57  internal::sub_assign_op<Scalar, typename OtherDerived::Scalar>());
58  return m_expression;
59  }
60 
61  EIGEN_DEVICE_FUNC ExpressionType& expression() const { return m_expression; }
62 
63  protected:
64  ExpressionType& m_expression;
65 };
66 
95 template <typename Derived>
97  return NoAlias<Derived, Eigen::MatrixBase>(derived());
98 }
99 
100 } // end namespace Eigen
101 
102 #endif // EIGEN_NOALIAS_H
Pseudo expression providing an operator = assuming no aliasing.
Definition: NoAlias.h:34
Namespace containing all symbols from the Eigen library.
Definition: B01_Experimental.dox:1
NoAlias< Derived, Eigen::MatrixBase > noalias()
Definition: NoAlias.h:96