Used to enable function arguments of a type T to be cached in a memoized version of the function.
More...
#include <Memoization.hpp>
Public Types | |
| using | Type = Decay< T > |
The type T without const, reference, and pointer specifiers. | |
| using | CacheType = Type |
The type of the object constructed with a given object of type T. More... | |
Static Public Member Functions | |
| static auto | equal (const CacheType &a, const Type &b) |
Check if a, of type CacheType, is equal to b, of type T. More... | |
| static auto | assign (CacheType &a, const Type &b) |
Assign the value of b, of type T, into a, of type CacheType. More... | |
Detailed Description
template<typename T>
struct Reaktoro::MemoizationTraits< T >
Used to enable function arguments of a type T to be cached in a memoized version of the function.
Member Typedef Documentation
◆ CacheType
The type of the object constructed with a given object of type T.
Consider three cases for type T and the respective default type for CacheType using Type = Decay<T>:
Case 1: T is const real& and CacheType is real. Case 2: T is ArrayXrConstRef and CacheType is also ArrayXrConstRef.
In Case 1, the default type for CacheType is suitable, since real implements a default constructor, which will be used to construct a cache object for arguments of this type.
In Case 2, CacheType is not a suitable type for a cache object, because ArrayXrConstRef does not implement a default constructor. In this case, CacheType should be defined to be ArrayXr instead.
Member Function Documentation
◆ equal()
Check if a, of type CacheType, is equal to b, of type T.
Redefine this function in a template specialization for type T if the default implementation using operator==(const CacheType&, const T&) is not adequate. For example, operator== for Eigen::ArrayBase<Derived> objects return an expression that needs to be evaluated with methods all() or any(). Thus, in order for memoization of functions with this array type to compile, a template specialization is needed for Eigen::ArrayBase<Derived>>.
◆ assign()
Assign the value of b, of type T, into a, of type CacheType.
Redefine this function in a template specialization for type T if the default implementation using CacheType::operator= is not adequate.
The documentation for this struct was generated from the following files:
- Reaktoro/Common/Matrix.hpp
- Reaktoro/Common/Memoization.hpp