mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-09-16 11:23:14 +08:00
add "remap" snippet using placement new
This commit is contained in:
parent
5b4c3b21f3
commit
666ade0c93
@ -40,6 +40,12 @@
|
|||||||
* It can be used to let Eigen interface without any overhead with non-Eigen data structures,
|
* It can be used to let Eigen interface without any overhead with non-Eigen data structures,
|
||||||
* such as plain C arrays or structures from other libraries.
|
* such as plain C arrays or structures from other libraries.
|
||||||
*
|
*
|
||||||
|
* \b Tips: to change the array of data mapped by a Map object, you can use the C++
|
||||||
|
* placement new syntax:
|
||||||
|
*
|
||||||
|
* Example: \include Map_placement_new.cpp
|
||||||
|
* Output: \verbinclude Map_placement_new.out
|
||||||
|
*
|
||||||
* This class is the return type of Matrix::Map() but can also be used directly.
|
* This class is the return type of Matrix::Map() but can also be used directly.
|
||||||
*
|
*
|
||||||
* \sa Matrix::Map()
|
* \sa Matrix::Map()
|
||||||
|
5
doc/snippets/Map_placement_new.cpp
Normal file
5
doc/snippets/Map_placement_new.cpp
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
int data[] = {1,2,3,4,5,6,7,8,9};
|
||||||
|
Map<RowVectorXi> v(data,4);
|
||||||
|
cout << "The mapped vector v is: " << v << "\n";
|
||||||
|
new (&v) Map<RowVectorXi>(data+4,5);
|
||||||
|
cout << "Now v is: " << v << "\n";
|
Loading…
x
Reference in New Issue
Block a user