From 4d302a080c775290acf23935f233cebbe19540f4 Mon Sep 17 00:00:00 2001 From: Gael Guennebaud Date: Thu, 19 Jan 2017 20:34:18 +0100 Subject: Recover compile-time size from seq(A,B) when A and B are fixed values. (c++11 only) --- test/indexed_view.cpp | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) (limited to 'test/indexed_view.cpp') diff --git a/test/indexed_view.cpp b/test/indexed_view.cpp index 751f98344..e70a9c616 100644 --- a/test/indexed_view.cpp +++ b/test/indexed_view.cpp @@ -55,8 +55,7 @@ is_same_eq(const T1& a, const T2& b) } template -typename internal::enable_if::value,bool>::type -is_same_seq_type(const T1& a, const T2& b) +bool is_same_seq(const T1& a, const T2& b) { bool ok = a.first()==b.first() && a.size() == b.size() && Index(a.incrObject())==Index(b.incrObject());; if(!ok) @@ -67,6 +66,15 @@ is_same_seq_type(const T1& a, const T2& b) return ok; } +template +typename internal::enable_if::value,bool>::type +is_same_seq_type(const T1& a, const T2& b) +{ + return is_same_seq(a,b); +} + + + #define VERIFY_EQ_INT(A,B) VERIFY_IS_APPROX(int(A),int(B)) void check_indexed_view() @@ -193,6 +201,14 @@ void check_indexed_view() VERIFY( is_same_seq_type( seqN(2,fix(5),3), seqN(2,5,fix(3)) ) ); 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 + VERIFY( is_same_seq_type( seq(fix<2>,fix<5>), seqN(fix<2>,fix<4>) ) ); +#else + // sorry, no compile-time size recovery in c++98/03 + VERIFY( is_same_seq( seq(fix<2>,fix<5>), seqN(fix<2>,fix<4>) ) ); +#endif + VERIFY( (A(seqN(2,fix<5>), 5)).RowsAtCompileTime == 5); VERIFY( (A(4, all)).ColsAtCompileTime == Dynamic); VERIFY( (A(4, all)).RowsAtCompileTime == 1); -- cgit v1.2.3