mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-05-15 14:16:07 -06:00
New Core Tutorial
git-svn-id: svn://ultimatepp.org/upp/trunk@10538 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
dd88feaf2e
commit
6c22e727de
37 changed files with 3125 additions and 0 deletions
25
tutorial/CoreTutorial/Array.cpp
Normal file
25
tutorial/CoreTutorial/Array.cpp
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
#include "Tutorial.h"
|
||||
|
||||
void ArrayTutorial()
|
||||
{
|
||||
/// .Array flavor
|
||||
|
||||
/// If elements are not `Moveable` and therefore cannot be stored in `Vector` flavor, they
|
||||
/// can still be stored in `Array` flavor. Another reason for using Array is the need for
|
||||
/// referencing elements - Array flavor never invalidates references or pointers to them.
|
||||
/// Finally, if sizeof(T) is large (say more than 100-200 bytes), using Array might be better
|
||||
/// from performance perspective.
|
||||
|
||||
/// Example of elements that cannot be stored in Vector flavor are standard library objects like
|
||||
/// `std::string` (because obviously, standard library knows nothing about U++ Moveable
|
||||
/// concept):
|
||||
|
||||
Array<std::string> as;
|
||||
for(int i = 0; i < 4; i++)
|
||||
as.Add("Test");
|
||||
|
||||
for(auto s : as)
|
||||
DUMP(s.c_str());
|
||||
|
||||
///
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue