mirror of
https://gitlab.com/libeigen/eigen.git
synced 2026-04-10 11:34:33 +08:00
Merged in ezhulenev/eigen-01 (pull request PR-523)
Compile time detection for unimplemented stl-style iterators
This commit is contained in:
@@ -583,11 +583,23 @@ template<typename Derived> class DenseBase
|
||||
typedef typename internal::conditional< (Flags&DirectAccessBit)==DirectAccessBit,
|
||||
internal::pointer_based_stl_iterator<Derived>,
|
||||
internal::generic_randaccess_stl_iterator<Derived>
|
||||
>::type iterator;
|
||||
>::type iterator_type;
|
||||
|
||||
typedef typename internal::conditional< (Flags&DirectAccessBit)==DirectAccessBit,
|
||||
internal::pointer_based_stl_iterator<const Derived>,
|
||||
internal::generic_randaccess_stl_iterator<const Derived>
|
||||
>::type const_iterator_type;
|
||||
|
||||
// Stl-style iterators are supported only for vectors.
|
||||
|
||||
typedef typename internal::conditional< IsVectorAtCompileTime,
|
||||
iterator_type,
|
||||
internal::not_an_iterator<const Derived>
|
||||
>::type iterator;
|
||||
|
||||
typedef typename internal::conditional< IsVectorAtCompileTime,
|
||||
const_iterator_type,
|
||||
internal::not_an_iterator<const Derived>
|
||||
>::type const_iterator;
|
||||
#endif
|
||||
|
||||
|
||||
@@ -11,6 +11,19 @@ namespace Eigen {
|
||||
|
||||
namespace internal {
|
||||
|
||||
// Iterator type for XprType that do not support stl-style iterators. Allows to
|
||||
// detect that expression does not support stl iterators at compile time.
|
||||
template<typename XprType>
|
||||
class not_an_iterator
|
||||
{
|
||||
not_an_iterator() : mp_xpr(0), m_index(0) {}
|
||||
not_an_iterator(XprType& xpr, Index index) : mp_xpr(&xpr), m_index(index) {}
|
||||
|
||||
protected:
|
||||
XprType *mp_xpr;
|
||||
Index m_index;
|
||||
};
|
||||
|
||||
template<typename XprType,typename Derived>
|
||||
class indexed_based_stl_iterator_base
|
||||
{
|
||||
|
||||
@@ -135,6 +135,7 @@ template<typename Derived> class SolverBase;
|
||||
template<typename XprType> class InnerIterator;
|
||||
|
||||
namespace internal {
|
||||
template<typename XprType> class not_an_iterator;
|
||||
template<typename XprType> class generic_randaccess_stl_iterator;
|
||||
template<typename XprType> class pointer_based_stl_iterator;
|
||||
template<typename XprType, DirectionType Direction> class subvector_stl_iterator;
|
||||
|
||||
Reference in New Issue
Block a user