From a0173a4a4596037bfe7f5866c72f9bd25d424352 Mon Sep 17 00:00:00 2001 From: Matthias Andreas Benkard Date: Sun, 9 Dec 2012 12:06:19 +0100 Subject: Do not presume the use of shared_ptr. --- README.md | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) (limited to 'README.md') diff --git a/README.md b/README.md index 776431e..ff2777d 100644 --- a/README.md +++ b/README.md @@ -48,14 +48,13 @@ wherever your compiler can find them and `#include `. The API primarily consists of the `cell` and `formula_cell` class templates. Using a `formula_cell` is easy: simply construct -one using `formula_cell::make()` and use the `reset` method to set -a formula to compute the value of the cell: +one and use the `reset` method to set a formula to compute the value +of the cell: typedef formula_cell fcell; - typedef shared_ptr sfcell; - sfcell x = fcell::make(); - x->reset([=](){ return 5; }); + fcell x; + x.reset([](){ return 5; }); For convenience, you can also just write something like `x->reset(5);` for setting a constant value. @@ -63,8 +62,8 @@ for setting a constant value. In order to create a dependent cell, simply make use of the other cell's value in the formula: - sfcell double_x = fcell::make(); - double_x->reset([=](){ return 2 * x->get(); }); + fcell double_x; + double_x.reset([&](){ return 2 * x.get(); }); From now on, whenever `x` changes, `double_x` will be updated accordingly. @@ -72,9 +71,9 @@ accordingly. You can create change event observers by writing formulas that make use of an observed cell and return a dummy value: - sfcell simple_observer = fcell::make(); - simple_observer->reset([=]() -> double { - (void)double_x->get(); + fcell simple_observer; + simple_observer.reset([&]() -> double { + (void)double_x.get(); std::cout << "double_x has changed!" << std::endl; return 0; }); -- cgit v1.2.3