mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-05-15 22:02:49 -06:00
.CoreTutorial
git-svn-id: svn://ultimatepp.org/upp/trunk@10541 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
9e9b622eaf
commit
20304de982
5 changed files with 148 additions and 17 deletions
22
tutorial/CoreTutorial/CapturingContainers.cpp
Normal file
22
tutorial/CoreTutorial/CapturingContainers.cpp
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
#include "Tutorial.h"
|
||||
|
||||
void CapturingContainers()
|
||||
{
|
||||
/// .Capturing U++ containers into lambdas
|
||||
|
||||
/// Capturing objects with pick/clone semantics can be achieved using %capture with an
|
||||
/// initializer%:
|
||||
|
||||
Vector<int> x{ 1, 2 };
|
||||
Array<String> y{ "one", "two" };
|
||||
Event<> ev = [x = pick(x), y = clone(y)] { DUMP(x); DUMP(y); };
|
||||
|
||||
DUMP(x); // x is picked, so empty
|
||||
DUMP(y); // y was cloned, so it retains original value
|
||||
|
||||
LOG("About to invoke event");
|
||||
|
||||
ev();
|
||||
|
||||
///
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue