Raven Engine v0.1
A modern 3D Game Engine
Loading...
Searching...
No Matches
FunctionCache.h File Reference

Memoization wrapper for stateless callables. More...

#include <flat_map>
#include <type_traits>
#include <utility>
#include <functional>
#include <ranges>
#include "Raven/Core/MemoryTracker.h"

Classes

struct  Raven::function_traits< ReturnType(ClassType::*)(Args...) const >
 Specialization of function_traits for const (non-mutable) lambdas and functors. More...
struct  Raven::function_traits< ReturnType(ClassType::*)(Args...)>
 Specialization of function_traits for mutable lambdas and functors. More...
struct  Raven::function_traits< ReturnType(*)(Args...)>
 Specialization of function_traits for raw function pointers. More...
class  Raven::function_cache< Callable >
 Memoization wrapper for a stateless callable. More...

Namespaces

namespace  Raven

Detailed Description

Memoization wrapper for stateless callables.

Provides function_cache, a template class that wraps a stateless callable and caches its return values in a std::flat_map keyed by argument tuple. Subsequent calls with identical arguments return the cached result directly.

Warning
Each instantiation generates roughly 150 lines of assembly. Only use where the call cost justifies the cache overhead. Not suitable for functions that modify values through references or pointers.