-
Notifications
You must be signed in to change notification settings - Fork 754
Closed
Description
Would it make sense to make dim
a function like the following? (where Dim
is the exact same type as the current dim
, just renamed)
template <std::ptrdiff_t N>
constexpr Dim<N> dim() noexcept {
static_assert(N >= 0,"something something less than zero");
return Dim<N>();
}
template <std::ptrdiff_t N = dynamic_range>
constexpr Dim<N> dim(std::ptrdiff_t n) noexcept {
static_assert(N == dynamic_range,"something something dynamic_range");
return Dim<>(n);
}
void f(){
dim<dynamic_range>(4);//still compiles
dim<>(4);//still compiles
dim(4);//now compiles
dim<4>();//now compiles
dim<4>(4);//does not compile
dim();//does not compile
dim<dynamic_range>();//does not compile
}
Of course Dim
does not have to be the name of the type, it is backwards compatible with most user-code. The exception to that is if someone wrote their own as_span
-like function which takes dim
s or for some reason decides to create variables of the type (without auto
), which I would expect to be reasonably rare, and easy to mitigate since these uses will almost certainly cause a compiler error, and the solution is a matter of replacing a few symbols with slightly different ones.
Metadata
Metadata
Assignees
Labels
No labels