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 <string> |
10 | // include:intro/start |
11 | #include <immer/map.hpp> |
12 | int main() |
13 | { |
14 | const auto v0 = immer::map<std::string, int>{}; |
15 | const auto v1 = v0.set("hello" , 42); |
16 | assert(v0["hello" ] == 0); |
17 | assert(v1["hello" ] == 42); |
18 | |
19 | const auto v2 = v1.erase("hello" ); |
20 | assert(*v1.find("hello" ) == 42); |
21 | assert(!v2.find("hello" )); |
22 | } |
23 | // include:intro/end |
24 | |