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 | struct owner |
27 | { |
28 | operator edit () const { return {}; } |
29 | }; |
30 | |
31 | struct ownee |
32 | { |
33 | ownee& operator=(edit) { return *this; }; |
34 | bool can_mutate(edit) const { return false; } |
35 | bool owned() const { return false; } |
36 | }; |
37 | |
38 | static owner noone; |
39 | }; |
40 | }; |
41 | }; |
42 | |
43 | template <typename HP> |
44 | typename no_transience_policy::apply<HP>::type::owner |
45 | no_transience_policy::apply<HP>::type::noone = {}; |
46 | |
47 | } // namespace immer |
48 | |