/src/immer/immer/transience/no_transience_policy.hpp
Line | Count | Source |
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 | | #pragma once |
10 | | |
11 | | namespace immer { |
12 | | |
13 | | /*! |
14 | | * Disables any special *transience* tracking. To be used when |
15 | | * *reference counting* is available instead. |
16 | | */ |
17 | | struct no_transience_policy |
18 | | { |
19 | | template <typename> |
20 | | struct apply |
21 | | { |
22 | | struct type |
23 | | { |
24 | | struct edit |
25 | | {}; |
26 | | |
27 | | struct owner |
28 | | { |
29 | | operator edit() const { return {}; } |
30 | | }; |
31 | | |
32 | | struct ownee |
33 | | { |
34 | 81.9k | ownee& operator=(edit) { return *this; }; |
35 | 24.0k | bool can_mutate(edit) const { return false; } |
36 | | bool owned() const { return false; } |
37 | | }; |
38 | | |
39 | | static owner noone; |
40 | | }; |
41 | | }; |
42 | | }; |
43 | | |
44 | | template <typename HP> |
45 | | typename no_transience_policy::apply<HP>::type::owner |
46 | | no_transience_policy::apply<HP>::type::noone = {}; |
47 | | |
48 | | } // namespace immer |