diff --git a/include/vectorwrapper/sequence_range.hpp b/include/vectorwrapper/sequence_range.hpp index cfb0447..8b47084 100644 --- a/include/vectorwrapper/sequence_range.hpp +++ b/include/vectorwrapper/sequence_range.hpp @@ -41,9 +41,42 @@ namespace vwr { }; } //namespace op + namespace implem { + //sets value to the index of the first I >= MAX or to sizeof...(I) if + //no such value is found + template + struct find_ge_than_max; + + template + struct find_ge_than_max { + static constexpr size_type value = + IDX + (I >= MAX ? 0 : 1); + }; + template + struct find_ge_than_max { + static constexpr size_type value = + (L >= MAX ? IDX : find_ge_than_max::value); + }; + + //helper to identify the invalid index in the build error messages + template + struct is_invalid_index { + static_assert(not INVALID, + "Invalid index specified, indices must all be >= 0 and <= dimensions" + ); + enum { + value = 0 + }; + }; + } //namespace implem + template class sequence_range_iterator : OP, CMP { - //static_assert(VectorWrapperInfo::dimensions >= sizeof...(I), "Start index out of valid range"); + static_assert(not implem::is_invalid_index< + implem::find_ge_than_max::value, + sizeof...(I) != implem::find_ge_than_max::value + >::value, ""); + static_assert(sizeof...(I) > 0, "At least one index must be specified"); public: sequence_range_iterator (const V& parFrom, const V& parUpper); sequence_range_iterator (const V& parCurrent, const V& parFrom, const V& parUpper);