0.6.0
C++ to UML diagram generator based on Clang
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Private Attributes | List of all members
clanguml::util::memoized< T, Ret, bool > Class Template Reference

Detailed Description

template<typename T, typename Ret>
class clanguml::util::memoized< T, Ret, bool >

Definition at line 79 of file memoized.h.

#include <memoized.h>

Public Types

using key_t = bool
 
using value_t = Ret
 

Public Member Functions

template<typename F >
auto memoize (bool is_complete, F f, bool arg) const
 
void invalidate (bool key) const
 

Private Attributes

std::optional< Ret > true_value_
 
std::optional< Ret > false_value_
 

Member Typedef Documentation

◆ key_t

template<typename T , typename Ret >
using clanguml::util::memoized< T, Ret, bool >::key_t = bool

Definition at line 81 of file memoized.h.

◆ value_t

template<typename T , typename Ret >
using clanguml::util::memoized< T, Ret, bool >::value_t = Ret

Definition at line 82 of file memoized.h.

Member Function Documentation

◆ invalidate()

template<typename T , typename Ret >
void clanguml::util::memoized< T, Ret, bool >::invalidate ( bool  key) const
inline

Definition at line 101 of file memoized.h.

102 {
103 if (key)
104 true_value_.reset();
105 else
106 false_value_.reset();
107 }

◆ memoize()

template<typename T , typename Ret >
template<typename F >
auto clanguml::util::memoized< T, Ret, bool >::memoize ( bool  is_complete,
f,
bool  arg 
) const
inline

Definition at line 84 of file memoized.h.

85 {
86 if (!is_complete)
87 return f(arg);
88
89 const auto key = arg;
90 if (key && !true_value_) {
91 true_value_ = f(arg);
92 }
93
94 if (!key && !false_value_) {
95 false_value_ = f(arg);
96 }
97
98 return key ? *true_value_ : *false_value_; // NOLINT
99 }

Member Data Documentation

◆ false_value_

template<typename T , typename Ret >
std::optional<Ret> clanguml::util::memoized< T, Ret, bool >::false_value_
mutableprivate

Definition at line 111 of file memoized.h.

◆ true_value_

template<typename T , typename Ret >
std::optional<Ret> clanguml::util::memoized< T, Ret, bool >::true_value_
mutableprivate

Definition at line 110 of file memoized.h.


The documentation for this class was generated from the following file: