Iros
 
Loading...
Searching...
No Matches
non_propagating_cache.h
Go to the documentation of this file.
1#pragma once
2
3#include "di/meta/language.h"
4#include "di/util/addressof.h"
6
7namespace di::util {
8template<concepts::Object T>
9class NonPropagatingCache : public Optional<T> {
10public:
12 using Parent::Parent;
13
15 constexpr NonPropagatingCache(NonPropagatingCache&& other) : Optional<T>() { other.reset(); }
16
17 template<concepts::ConvertibleTo<T> U>
18 constexpr auto operator=(U&& value) -> NonPropagatingCache& {
19 this->emplace(util::forward<U>(value));
20 return *this;
21 }
22
23 constexpr auto operator=(NonPropagatingCache const& other) -> NonPropagatingCache& {
24 if (util::addressof(other) != this) {
25 this->reset();
26 }
27 return *this;
28 }
30 this->reset();
31 other.reset();
32 return *this;
33 }
34
35 template<typename I>
36 constexpr auto emplace_deref(I const& it) -> T& requires(requires { T(*it); }) {
37 this->reset();
38 return this->emplace(*it);
39 }
40};
41}
42
43namespace di {
44using util::NonPropagatingCache;
45}
Optional< T > Parent
Definition non_propagating_cache.h:11
constexpr auto operator=(NonPropagatingCache const &other) -> NonPropagatingCache &
Definition non_propagating_cache.h:23
constexpr NonPropagatingCache(NonPropagatingCache const &)
Definition non_propagating_cache.h:14
constexpr auto operator=(U &&value) -> NonPropagatingCache &
Definition non_propagating_cache.h:18
return this emplace * it
Definition non_propagating_cache.h:38
constexpr NonPropagatingCache(NonPropagatingCache &&other)
Definition non_propagating_cache.h:15
constexpr auto emplace_deref(I const &it) -> T &requires(
Definition non_propagating_cache.h:36
constexpr auto operator=(NonPropagatingCache &&other) -> NonPropagatingCache &
Definition non_propagating_cache.h:29
Definition optional_forward_declaration.h:5
Definition vocab.h:96
Definition zstring_parser.h:9