17 #include <type_traits> 40 : min{min_}, max{max_}, stride{stride_} {}
46 : min{min_}, max{max_}, stride{1} {
47 static_assert(std::is_integral<value_type>::value,
48 "Default stride is only defined for integral types.");
54 auto const length = max -
min;
55 return static_cast<std::size_t
>(floor(length / stride)) + std::size_t{1};
Name namespace for CortidQCT library.
Definition: CortidQCT.h:23
float value_type
type of the elements contained in the range
Definition: DiscreteRange.h:28
Type representing a discrete closed, stridable range.
Definition: DiscreteRange.h:26
value_type stride
stride, i.e. distance between two consecutive elements
Definition: DiscreteRange.h:35
constexpr value_type nThElement(std::size_t n) const noexcept
Definition: DiscreteRange.h:62
value_type max
maximum element
Definition: DiscreteRange.h:33
constexpr std::size_t numElements() const noexcept
Returns the number of elements in the range.
Definition: DiscreteRange.h:52
constexpr DiscreteRange(value_type min_, value_type max_) noexcept
Definition: DiscreteRange.h:45
constexpr DiscreteRange< T > discreteRange(T min, T max, T stride) noexcept
Convenient creator function.
Definition: DiscreteRange.h:77
value_type min
minimum element
Definition: DiscreteRange.h:31
constexpr DiscreteRange(value_type min_, value_type max_, value_type stride_) noexcept
Constructs a discrete range.
Definition: DiscreteRange.h:38