1 | // |
2 | // immer: immutable data structures for C++ |
3 | // Copyright (C) 2016, 2017, 2018 Juan Pedro Bolivar Puente |
4 | // |
5 | // This software is distributed under the Boost Software License, Version 1.0. |
6 | // See accompanying file LICENSE or copy at http://boost.org/LICENSE_1_0.txt |
7 | // |
8 | |
9 | #include <immer/box.hpp> |
10 | #include <cassert> |
11 | #include <string> |
12 | |
13 | int main() |
14 | { |
15 | { |
16 | // include:update/start |
17 | auto v1 = immer::box<std::string>{"hello" }; |
18 | auto v2 = v1.update([&] (auto l) { |
19 | return l + ", world!" ; |
20 | }); |
21 | |
22 | assert((v1 == immer::box<std::string>{"hello" })); |
23 | assert((v2 == immer::box<std::string>{"hello, world!" })); |
24 | // include:update/end |
25 | } |
26 | } |
27 | |