Eigen  5.0.1
 
Loading...
Searching...
No Matches
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// SPDX-License-Identifier: MPL-2.0
10
11#ifndef EIGEN_NOALIAS_H
12#define EIGEN_NOALIAS_H
13
14// IWYU pragma: private
15#include "./InternalHeaderCheck.h"
16
17namespace Eigen {
18
34template <typename ExpressionType, template <typename> class StorageBase>
35class NoAlias {
36 public:
37 using Scalar = typename ExpressionType::Scalar;
38
39 EIGEN_DEVICE_FUNC constexpr explicit NoAlias(ExpressionType& expression) : m_expression(expression) {}
40
41 template <typename OtherDerived>
42 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE ExpressionType& operator=(const StorageBase<OtherDerived>& other) {
43 call_assignment_no_alias(m_expression, other.derived(),
44 internal::assign_op<Scalar, typename OtherDerived::Scalar>());
45 return m_expression;
46 }
47
48 template <typename OtherDerived>
49 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE ExpressionType& operator+=(const StorageBase<OtherDerived>& other) {
50 call_assignment_no_alias(m_expression, other.derived(),
51 internal::add_assign_op<Scalar, typename OtherDerived::Scalar>());
52 return m_expression;
53 }
54
55 template <typename OtherDerived>
56 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE ExpressionType& operator-=(const StorageBase<OtherDerived>& other) {
57 call_assignment_no_alias(m_expression, other.derived(),
58 internal::sub_assign_op<Scalar, typename OtherDerived::Scalar>());
59 return m_expression;
60 }
61
62 EIGEN_DEVICE_FUNC constexpr ExpressionType& expression() const { return m_expression; }
63
64 protected:
65 ExpressionType& m_expression;
66};
67
96template <typename Derived>
100
101} // end namespace Eigen
102
103#endif // EIGEN_NOALIAS_H
NoAlias< Derived, Eigen::MatrixBase > noalias()
Definition NoAlias.h:97
Pseudo expression providing an operator = assuming no aliasing.
Definition NoAlias.h:35