Classes | Functions
CachedFunction.hpp File Reference

Defines class CachedFunction. More...

#include <type_traits>
#include <unordered_map>
#include <utility>

Go to the source code of this file.

Classes

class  CachedFunction< Function, Map >
 A function wrapper that caches function values. More...
 

Functions

template<typename Input , template< typename... > class Map = std::unordered_map, typename... MapArgs, typename Function , typename... PassedMapArgs>
auto make_cached_function (Function function, PassedMapArgs... map_args) noexcept
 Construct a CachedFunction wrapping the given function. More...
 

Detailed Description

Defines class CachedFunction.

Function Documentation

◆ make_cached_function()

template<typename Input , template< typename... > class Map = std::unordered_map, typename... MapArgs, typename Function , typename... PassedMapArgs>
auto make_cached_function ( Function  function,
PassedMapArgs...  map_args 
)
noexcept

Construct a CachedFunction wrapping the given function.

Example

auto cached = make_cached_function<const std::string&>(func);
// Specifying all the arguments
auto cached2 =
make_cached_function<const std::string&, std::map, decltype(comparator)>(
func, std::move(comparator));
Template Parameters
Inputfunction argument type
Mapclass template to use as the map holding the cache
Parameters
functionthe function
map_argsarguments to pass to the map constructor