Note that two values of type Stored are passed as template non-type parameters. This means that Stored can only be a (built-in) scalar type. Because only scalar types (apart from pointers and references) are allowed as non-type template parameters.
From reading the documentation one gets the impression that the library would work for any type that models Integer<T> concept, but that is not true. Even safe<safe<int>> doesn't work.
Technically, this could be fixed by using a different implementation of safe_base:
template<
classStored,
classMinMaxPolicy, // <-- type parameterclassP,
classE
>
classsafe_base
{
constexpr Stored Min = MinMaxPolicy::min();
constexpr Stored Max = MinMaxPolicy::max();
// ...
};
The text was updated successfully, but these errors were encountered:
Of course you're correct on all this. For now though I'm not going to address it. But I have added a long section in Pending issues section discussing it. For what it's worth, my preference would be to do something like:
template<typename T>
struct range {
T m_lowest;
T m_highest;
// default implementation
range(
const & T t_min,
const & T t_max
) :
m_lowest(std::numeric_limits<T>::lowest(t_min),
m_highest(std::numeric_limits<T>::max(t_max)
{}
};
Class template
safe_baseis defined as follows:Note that two values of type
Storedare passed as template non-type parameters. This means thatStoredcan only be a (built-in) scalar type. Because only scalar types (apart from pointers and references) are allowed as non-type template parameters.From reading the documentation one gets the impression that the library would work for any type that models
Integer<T>concept, but that is not true. Evensafe<safe<int>>doesn't work.Technically, this could be fixed by using a different implementation of
safe_base:The text was updated successfully, but these errors were encountered: