Concept checks convertible_to vs same_as
Should we always allow std::convertible_to
for the return types of grid functions, or is it sometimes better to be a bit more restrictive and test to std::same_as
. Specifically, I thought about iterator concept checks, e.g. in GridViewCodim
concept
template<class GV, int codim>
concept GridViewCodim = [...] &&
EntityIterator<typename GV::template Codim<codim>::Iterator> &&
requires(const GV gv)
{
{ gv.template begin<codim>() } -> std::convertible_to<typename GV::template Codim<codim>::Iterator>;
{ gv.template end<codim>() } -> std::convertible_to<typename GV::template Codim<codim>::Iterator>;
};
I think, the begin()
and end()
function should return exactly the iterator we have defined in the type aliases, i.e.,
{ gv.template begin<codim>() } -> std::same_as<typename GV::template Codim<codim>::Iterator>;
{ gv.template end<codim>() } -> std::same_as<typename GV::template Codim<codim>::Iterator>;
For some boolean methods, like EntitySeed::isValid()
we could also require that the return type is exactly bool
and not just convertible_to<bool>
. Or is this too restrictive?