mirror of
https://gitlab.com/libeigen/eigen.git
synced 2026-04-10 11:34:33 +08:00
Move Eigen::all,last,lastp1,lastN to Eigen::placeholders::.
These names are so common, IMO they should not exist directly in the `Eigen::` namespace. This prevents us from using the `last` or `all` names for any parameters or local variables, otherwise spitting out warnings about shadowing or hiding the global values. Many external projects (and our own examples) also heavily use ``` using namespace Eigen; ``` which means these conflict with external libraries as well, e.g. `std::fill(first,last,value)`. It seems originally these were placed in a separate namespace `Eigen::placeholders`, which has since been deprecated. I propose to un-deprecate this, and restore the original locations. These symbols are also imported into `Eigen::indexing`, which additionally imports `fix` and `seq`. An alternative is to remove the `placeholders` namespace and stick with `indexing`. NOTE: this is an API-breaking change. Fixes #2321.
This commit is contained in:
@@ -36,7 +36,12 @@
|
||||
#include <vector>
|
||||
#include "main.h"
|
||||
|
||||
using Eigen::placeholders::all;
|
||||
using Eigen::placeholders::last;
|
||||
using Eigen::placeholders::lastp1;
|
||||
|
||||
#if EIGEN_HAS_CXX11
|
||||
using Eigen::placeholders::lastN;
|
||||
#include <array>
|
||||
#endif
|
||||
|
||||
@@ -220,7 +225,7 @@ void check_indexed_view()
|
||||
VERIFY( is_same_seq_type( seqN(2,fix<5>(5),fix<-2>), seqN(2,fix<5>,fix<-2>()) ) );
|
||||
|
||||
VERIFY( is_same_seq_type( seq(2,fix<5>), seqN(2,4) ) );
|
||||
#if EIGEN_HAS_CXX11
|
||||
#if EIGEN_HAS_CXX11
|
||||
VERIFY( is_same_seq_type( seq(fix<2>,fix<5>), seqN(fix<2>,fix<4>) ) );
|
||||
VERIFY( is_same_seq( seqN(2,std::integral_constant<int,5>(),std::integral_constant<int,-2>()), seqN(2,fix<5>,fix<-2>()) ) );
|
||||
VERIFY( is_same_seq( seq(std::integral_constant<int,1>(),std::integral_constant<int,5>(),std::integral_constant<int,2>()),
|
||||
|
||||
@@ -10,6 +10,9 @@
|
||||
|
||||
#include "main.h"
|
||||
|
||||
using Eigen::placeholders::last;
|
||||
using Eigen::placeholders::all;
|
||||
|
||||
template<typename T1,typename T2>
|
||||
typename internal::enable_if<internal::is_same<T1,T2>::value,bool>::type
|
||||
is_same_eq(const T1& a, const T2& b)
|
||||
|
||||
@@ -133,6 +133,7 @@ void test_stl_iterators(int rows=Rows, int cols=Cols)
|
||||
ColMatrixType A = ColMatrixType::Random(rows,cols);
|
||||
const ColMatrixType& cA(A);
|
||||
RowMatrixType B = RowMatrixType::Random(rows,cols);
|
||||
using Eigen::placeholders::last;
|
||||
|
||||
Index i, j;
|
||||
|
||||
|
||||
@@ -19,6 +19,10 @@
|
||||
|
||||
#include "main.h"
|
||||
|
||||
using Eigen::placeholders::last;
|
||||
using Eigen::placeholders::lastp1;
|
||||
using Eigen::placeholders::all;
|
||||
|
||||
template<typename T1,typename T2>
|
||||
bool is_same_symb(const T1& a, const T2& b, Index size)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user