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 > Class Template Reference

Detailed Description

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

Definition at line 56 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) const
 
void invalidate () const
 

Private Attributes

std::optional< Ret > value_
 

Member Typedef Documentation

◆ key_t

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

Definition at line 58 of file memoized.h.

◆ value_t

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

Definition at line 59 of file memoized.h.

Member Function Documentation

◆ invalidate()

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

Definition at line 73 of file memoized.h.

73{ value_.reset(); }

◆ memoize()

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

Definition at line 61 of file memoized.h.

62 {
63 if (!is_complete)
64 return f();
65
66 if (!value_) {
67 value_ = f();
68 }
69
70 return *value_; // NOLINT
71 }

Member Data Documentation

◆ value_

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

Definition at line 76 of file memoized.h.


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