diff --git a/include/array_view.h b/include/array_view.h index ff449c1..ac29dcc 100644 --- a/include/array_view.h +++ b/include/array_view.h @@ -1,17 +1,17 @@ -/////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2015 Microsoft Corporation. All rights reserved. -// -// This code is licensed under the MIT License (MIT). -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. -// +/////////////////////////////////////////////////////////////////////////////// +// +// Copyright (c) 2015 Microsoft Corporation. All rights reserved. +// +// This code is licensed under the MIT License (MIT). +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +// /////////////////////////////////////////////////////////////////////////////// #pragma once @@ -41,17 +41,17 @@ #ifndef _NOEXCEPT #ifdef SAFER_CPP_TESTING -#define _NOEXCEPT -#else +#define _NOEXCEPT +#else #define _NOEXCEPT noexcept -#endif +#endif #else // _NOEXCEPT #ifdef SAFER_CPP_TESTING #undef _NOEXCEPT -#define _NOEXCEPT -#endif +#define _NOEXCEPT +#endif #endif // _NOEXCEPT @@ -295,7 +295,7 @@ public: template _CONSTEXPR index(const index &other) : Base(other) { - } + } _CONSTEXPR static index shift_left(const index& other) _NOEXCEPT { value_type (&arr)[rank] = (value_type(&)[rank])(*(other.elems + 1)); @@ -328,14 +328,14 @@ public: using reference = std::add_lvalue_reference_t; using const_reference = std::add_lvalue_reference_t>; using size_type = ValueType; - + _CONSTEXPR index() _NOEXCEPT : value(0) { } _CONSTEXPR index(value_type e0) _NOEXCEPT : value(e0) { } - _CONSTEXPR index(const value_type(&values)[1]) _NOEXCEPT : index(values[0]) + _CONSTEXPR index(const value_type(&values)[1]) _NOEXCEPT : index(values[0]) { } // Preconditions: il.size() == rank @@ -619,11 +619,11 @@ namespace details const ptrdiff_t cur = this->Base::totalSize() * arr[Dim]; return static_cast(cur) < static_cast(m_bound) ? cur + last : -1; } - + size_t totalSize() const _NOEXCEPT { return m_bound; } - + SizeType elementNum() const _NOEXCEPT { return static_cast(totalSize() / this->Base::totalSize()); } @@ -712,20 +712,20 @@ namespace details template auto helpBoundsRangeConvertible(SourceType, TargetType, ...) -> std::false_type; - + template - struct BoundsRangeConvertible2 : decltype(helpBoundsRangeConvertible(SourceType(), TargetType(), - std::integral_constant())) + struct BoundsRangeConvertible2 : decltype(helpBoundsRangeConvertible(SourceType(), TargetType(), + std::integral_constant())) {}; template struct BoundsRangeConvertible2 : std::true_type {}; template - struct BoundsRangeConvertible : decltype(helpBoundsRangeConvertible(SourceType(), TargetType(), - std::integral_constant::value || TargetType::CurrentRange == dynamic_range || SourceType::CurrentRange == dynamic_range)>())) + struct BoundsRangeConvertible : decltype(helpBoundsRangeConvertible(SourceType(), TargetType(), + std::integral_constant::value || TargetType::CurrentRange == dynamic_range || SourceType::CurrentRange == dynamic_range)>())) {}; template struct BoundsRangeConvertible : std::true_type {}; @@ -778,7 +778,7 @@ class static_bounds MyRanges m_ranges; _CONSTEXPR static_bounds(const MyRanges & range) : m_ranges(range) { } - + template friend class static_bounds; public: @@ -795,7 +795,7 @@ public: using mapping_type = contiguous_mapping_tag; public: _CONSTEXPR static_bounds(const static_bounds &) = default; - + template , details::BoundsRanges >::value>> _CONSTEXPR static_bounds(const static_bounds &other): @@ -808,7 +808,7 @@ public: fail_fast_assert(MyRanges::DynamicNum == il.size(), "Size of the initializer list must match the rank of the array"); fail_fast_assert(m_ranges.totalSize() <= details::SizeTypeTraits::max_value, "Size of the range is larger than the max element of the size type"); } - + _CONSTEXPR static_bounds() = default; _CONSTEXPR static_bounds & operator = (const static_bounds & otherBounds) @@ -826,7 +826,7 @@ public: { return rank > 1 ? slice().size() : 1; } - + _CONSTEXPR size_type size() const _NOEXCEPT { return static_cast(m_ranges.totalSize()); @@ -836,12 +836,12 @@ public: { return static_cast(m_ranges.totalSize()); } - + _CONSTEXPR size_type linearize(const index_type & idx) const { return m_ranges.linearize(idx); } - + _CONSTEXPR bool contains(const index_type& idx) const _NOEXCEPT { return m_ranges.contains(idx) != -1; @@ -858,31 +858,31 @@ public: static_assert(Dim < rank, "dimension should be less than rank (dimension count starts from 0)"); return details::createTypeListIndexer(m_ranges).template get().elementNum(); } - + _CONSTEXPR index_type index_bounds() const _NOEXCEPT { index_type extents; m_ranges.serialize(extents); return extents; } - + template _CONSTEXPR bool operator == (const static_bounds & rhs) const _NOEXCEPT { return this->size() == rhs.size(); } - + template _CONSTEXPR bool operator != (const static_bounds & rhs) const _NOEXCEPT { return !(*this == rhs); } - + _CONSTEXPR const_iterator begin() const _NOEXCEPT { return const_iterator(*this); } - + _CONSTEXPR const_iterator end() const _NOEXCEPT { index_type boundary; @@ -916,12 +916,12 @@ public: _CONSTEXPR strided_bounds(const strided_bounds &) = default; template - _CONSTEXPR strided_bounds(const strided_bounds &other) + _CONSTEXPR strided_bounds(const strided_bounds &other) : Base(other), m_strides(other.strides) { } - _CONSTEXPR strided_bounds(const index_type &extents, const index_type &strides) + _CONSTEXPR strided_bounds(const index_type &extents, const index_type &strides) : m_strides(strides) { for (size_t i = 0; i < rank; i++) @@ -932,8 +932,8 @@ public: { } _CONSTEXPR index_type strides() const _NOEXCEPT - { - return m_strides; + { + return m_strides; } _CONSTEXPR size_type total_size() const _NOEXCEPT { @@ -1588,9 +1588,9 @@ namespace details static_assert(BoundsType::dynamic_rank <= 1, "dynamic rank must less or equal to 1"); return newBoundsHelperImpl(totalSize, std::integral_constant()); } - + struct Sep{}; - + template T static_as_array_view_helper(Sep, Args... args) { @@ -1640,7 +1640,7 @@ struct array_view_options }; template -class array_view : public basic_array_view::value_type, +class array_view : public basic_array_view::value_type, static_bounds::size_type, FirstDimension, RestDimensions...>> { template @@ -1717,7 +1717,7 @@ public: } - // from begin, end pointers. We don't provide iterator pair since no way to guarantee the contiguity + // from begin, end pointers. We don't provide iterator pair since no way to guarantee the contiguity template ::value && details::LessThan::value>> // remove literal 0 case @@ -1862,12 +1862,12 @@ public: size_type size = this->bounds().total_size() - this->bounds().linearize(origin); return{ &this->operator[](origin), size, strided_bounds {extents, details::make_stride(Base::bounds())} }; } - + _CONSTEXPR reference operator[](const index_type& idx) const { return Base::operator[](idx); } - + template 1), typename Dummy = std::enable_if_t> _CONSTEXPR array_view operator[](size_type idx) const { @@ -1950,7 +1950,7 @@ public: using typename Base::iterator; using typename Base::const_iterator; using typename Base::reference; - + // from static array of size N template strided_array_view(value_type(&values)[N], bounds_type bounds) : Base(values, std::move(bounds)) @@ -1970,7 +1970,7 @@ public: { fail_fast_assert(this->bounds().total_size() <= av.bounds().total_size(), "Bounds cross data boundaries"); } - + // convertible template ::value_type, strided_bounds::size_type>>,