cxx11_maxsizevector.cpp
Go to the documentation of this file.
1 #include "main.h"
2 
3 #include <exception> // std::exception
4 
5 #include <unsupported/Eigen/CXX11/Tensor>
6 
7 struct Foo
8 {
9  static Index object_count;
10  static Index object_limit;
12 
13  Foo(int x=0) : dummy(x)
14  {
15 #ifdef EIGEN_EXCEPTIONS
16  // TODO: Is this the correct way to handle this?
17  if (Foo::object_count > Foo::object_limit) { std::cout << "\nThrow!\n"; throw Foo::Fail(); }
18 #endif
19  std::cout << '+';
21  eigen_assert((internal::UIntPtr(this) & (127)) == 0);
22  }
23  Foo(const Foo&)
24  {
25  std::cout << 'c';
27  eigen_assert((internal::UIntPtr(this) & (127)) == 0);
28  }
29 
30  ~Foo()
31  {
32  std::cout << '~';
34  }
35 
36  class Fail : public std::exception {};
37 };
38 
41 
42 
43 
44 EIGEN_DECLARE_TEST(cxx11_maxsizevector)
45 {
48  for(int r = 0; r < g_repeat; r++) {
49  Index rows = internal::random<Index>(3,30);
50  Foo::object_limit = internal::random<Index>(0, rows - 2);
51  std::cout << "object_limit = " << Foo::object_limit << std::endl;
52  bool exception_raised = false;
53 #ifdef EIGEN_EXCEPTIONS
54  try
55  {
56 #endif
57  std::cout << "\nVectorX m(" << rows << ");\n";
58  VectorX vect(rows);
59  for(int i=0; i<rows; ++i)
60  vect.push_back(Foo());
61 #ifdef EIGEN_EXCEPTIONS
62  VERIFY(false); // not reached if exceptions are enabled
63  }
64  catch (const Foo::Fail&) { exception_raised = true; }
65  VERIFY(exception_raised);
66 #endif
68 
69  {
71  VectorX vect2(rows, Foo());
73  }
75  std::cout << '\n';
76  }
77 }
gtsam.examples.DogLegOptimizerExample.int
int
Definition: DogLegOptimizerExample.py:111
Eigen::internal::UIntPtr
std::size_t UIntPtr
Definition: Meta.h:92
VERIFY_IS_EQUAL
#define VERIFY_IS_EQUAL(a, b)
Definition: main.h:386
Foo
Definition: jacobisvd.cpp:77
eigen_assert
#define eigen_assert(x)
Definition: Macros.h:1037
x
set noclip points set clip one set noclip two set bar set border lt lw set xdata set ydata set zdata set x2data set y2data set boxwidth set dummy x
Definition: gnuplot_common_settings.hh:12
rows
int rows
Definition: Tutorial_commainit_02.cpp:1
Foo::object_limit
static Index object_limit
Definition: ctorleak.cpp:8
Foo::~Foo
~Foo()
Definition: cxx11_maxsizevector.cpp:30
Foo
@ Foo
Definition: bug1213.cpp:4
Foo::dummy
int dummy
Definition: ctorleak.cpp:9
Eigen::g_repeat
static int g_repeat
Definition: main.h:169
Foo::object_count
static Index object_count
Definition: ctorleak.cpp:7
main.h
Foo::Fail
Definition: ctorleak.cpp:27
VectorX
Matrix< Scalar, Dynamic, 1 > VectorX
Definition: sparse_lu.cpp:41
Foo::Foo
Foo(const Foo &)
Definition: cxx11_maxsizevector.cpp:23
Foo::EIGEN_ALIGN_TO_BOUNDARY
EIGEN_ALIGN_TO_BOUNDARY(128) int dummy
EIGEN_DECLARE_TEST
EIGEN_DECLARE_TEST(cxx11_maxsizevector)
Definition: cxx11_maxsizevector.cpp:44
i
int i
Definition: BiCGSTAB_step_by_step.cpp:9
VERIFY
#define VERIFY(a)
Definition: main.h:380
Eigen::Index
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition: Meta.h:74
Eigen::MaxSizeVector
The MaxSizeVector class.
Definition: MaxSizeVector.h:31


gtsam
Author(s):
autogenerated on Mon Jul 1 2024 03:01:06