Bugzilla – Attachment 424 Details for
Bug 755
CommaInitializer bug in absence of RVO
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Forgot Password
Login:
[x]
This bugzilla service is closed. All entries have been migrated to
https://gitlab.com/libeigen/eigen
[patch]
Proof-of-concept patch to avoid assertions if RVO is deactivated
CommaInitializer.patch (text/plain), 3.46 KB, created by
Christoph Hertzberg
on 2014-03-07 17:31:04 UTC
(
hide
)
Description:
Proof-of-concept patch to avoid assertions if RVO is deactivated
Filename:
MIME Type:
Creator:
Christoph Hertzberg
Created:
2014-03-07 17:31:04 UTC
Size:
3.46 KB
patch
obsolete
>diff --git a/Eigen/src/Core/CommaInitializer.h b/Eigen/src/Core/CommaInitializer.h >--- a/Eigen/src/Core/CommaInitializer.h >+++ b/Eigen/src/Core/CommaInitializer.h >@@ -8,16 +8,34 @@ > // Public License v. 2.0. If a copy of the MPL was not distributed > // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. > > #ifndef EIGEN_COMMAINITIALIZER_H > #define EIGEN_COMMAINITIALIZER_H > > namespace Eigen { > >+namespace internal { >+ >+ >+ >+template<typename XprType> >+struct CommaInitializerRef { >+ typedef typename XprType::Index Index; >+ XprType& m_xpr; >+ Index m_row, m_col, m_currentBlockRows; >+ >+ explicit CommaInitializerRef(XprType& xpr, Index row, Index col, Index currentBlockRows) >+ : m_xpr(xpr), m_row(row), m_col(col), m_currentBlockRows(currentBlockRows) { >+ std::cout << __PRETTY_FUNCTION__ << std::endl; >+ } >+}; >+ >+} // end namespace internal >+ > /** \class CommaInitializer > * \ingroup Core_Module > * > * \brief Helper class used by the comma initializer operator > * > * This class is internally used to implement the comma initializer feature. It is > * the return type of MatrixBase::operator<<, and most of the time this is the only > * way it is used. >@@ -25,22 +43,54 @@ namespace Eigen { > * \sa \ref MatrixBaseCommaInitRef "MatrixBase::operator<<", CommaInitializer::finished() > */ > template<typename XprType> > struct CommaInitializer > { > typedef typename XprType::Scalar Scalar; > typedef typename XprType::Index Index; > >+ >+ operator internal::CommaInitializerRef<XprType>() >+ { >+ std::cout << __PRETTY_FUNCTION__ << std::endl; >+ internal::CommaInitializerRef<XprType> ret(m_xpr, m_row, m_col, m_currentBlockRows); >+ m_row = m_xpr.rows(); >+ m_col = m_xpr.cols(); >+ m_currentBlockRows = 0; >+ return ret; >+ } >+ >+ > inline CommaInitializer(XprType& xpr, const Scalar& s) > : m_xpr(xpr), m_row(0), m_col(1), m_currentBlockRows(1) > { > m_xpr.coeffRef(0,0) = s; > } >- >+ >+#ifdef EIGEN_HAVE_RVALUE_REFERENCES >+ inline CommaInitializer(CommaInitializer&& o) >+#else >+ inline CommaInitializer(CommaInitializer& o) >+#endif >+ : m_xpr(o.m_xpr), m_row(o.m_row), m_col(o.m_col), m_currentBlockRows(o.m_currentBlockRows) { >+ std::cout << __PRETTY_FUNCTION__ << std::endl; >+ o.m_row = m_xpr.rows(); >+ o.m_col = m_xpr.cols(); >+ o.m_currentBlockRows = 0; >+ } >+ >+#ifndef EIGEN_HAVE_RVALUE_REFERENCES >+ inline CommaInitializer(internal::CommaInitializerRef<XprType> o) >+ : m_xpr(o.m_xpr), >+ m_row(o.m_row), >+ m_col(o.m_col), >+ m_currentBlockRows(o.m_currentBlockRows) { >+ } >+#endif > template<typename OtherDerived> > inline CommaInitializer(XprType& xpr, const DenseBase<OtherDerived>& other) > : m_xpr(xpr), m_row(0), m_col(other.cols()), m_currentBlockRows(other.rows()) > { > m_xpr.block(0, 0, other.rows(), other.cols()) = other; > } > > /* inserts a scalar value in the target matrix */ >@@ -85,16 +135,17 @@ struct CommaInitializer > else > m_xpr.block(m_row, m_col, other.rows(), other.cols()) = other; > m_col += other.cols(); > return *this; > } > > inline ~CommaInitializer() > { >+ std::cout << __PRETTY_FUNCTION__ << m_row << std::endl; > eigen_assert((m_row+m_currentBlockRows) == m_xpr.rows() > && m_col == m_xpr.cols() > && "Too few coefficients passed to comma initializer (operator<<)"); > } > > /** \returns the built matrix once all its coefficients have been set. > * Calling finished is 100% optional. Its purpose is to write expressions > * like this:
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 755
: 424 |
425