Capabilities should implement value constant
The grid capabilities are something like boolean integral constants indicating whether a grid supports some feature. Unfortunately, these traits classes are implemented in a way incompatible with standard library traits, i.e., a constant with the uncommon name v
is provided instead of the more common name value
.
This might be just an small issue and one might get used to it, but me and others are so often fallen into this trap of using value
instead of v
that I came to this proposal and suggest to rename this into value
.
However, this is nothing that can be changed easily. The reason is that nearly all grids provide specializations for these capability classes. Is there a way to deprecate the old ::v
constant and provide the new ::value
in addition? Is there a smooth transition?
Maybe one could add a value constant aliases that provides a transition switch to old ::v
constants. Example:
// a utility to extract the value from the capability
template<class Capability>
constexpr auto getCapabilityValue(Dune::PriorityTag<2>) -> decltype(Capability::value)
{
return Capability::value;
}
template<class Capability>
[[deprecated]]
constexpr auto getCapabilityValue(Dune::PriorityTag<1>) -> decltype(Capability::v)
{
return Capability::v;
}
// the capability class
template<class Grid>
struct isCartesian
{
static constexpr bool value = false;
[[deprecated]] static constexpr bool v = value;
};
// the value alias for the capability
template<class Grid>
inline constexpr bool isCartesian_v = getCapabilityValue<isCartesian<Grid>>(Dune::PriorityTag<3>{});
With this, new code could directly go for isCartesian_v
and get deprecation warnings for grids that are not yet changed to ::value
. This would allow us to slowly change to the constant ::value
while old grids are still supported. Other code that uses ::v
will still work and get for some grids a deprecation warning, but not for all grids. If you would use the constant ::value
directly, not-updated grids would simply fail to compile.
If this is something we would agree on, then I would start updating all grids I have access to by providing the second constant ::value
in addition to ::v
.