Edit: highlighting the actual question with more context available if desired.
I want to implement the following method:
template &l
You can add code to define the persistent names of the types you wish to persist.
template <typename T> struct persistent_type;
template <> struct persistent_type<int>
{
static std::string_view name() { return "int"; }
}
template <> struct persistent_type<double>
{
static std::string_view name() { return "double"; }
}
etc.
And use them in make
template <typename T>
void make(std::string_view name, T value)
{
// Save the type name of the data, persistent_type<T>::name()
// Save the name of the data, name
// Save the data, value
}
When getting the value, use
template <typename T>
T get(std::string_view name)
{
// Read the type name and make sure it is equal to persistent_type<T>::name().
// Rest of your logic to read the object
}