mirror of
https://github.com/microsoft/GSL.git
synced 2024-11-03 17:56:43 -05:00
Reverting whitespace changes.
This commit is contained in:
parent
001a64c812
commit
57e5466395
@ -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 <typename OtherValueType>
|
||||
_CONSTEXPR index(const index<Rank, OtherValueType> &other) : Base(other)
|
||||
{
|
||||
}
|
||||
}
|
||||
_CONSTEXPR static index shift_left(const index<rank+1, value_type>& other) _NOEXCEPT
|
||||
{
|
||||
value_type (&arr)[rank] = (value_type(&)[rank])(*(other.elems + 1));
|
||||
@ -328,14 +328,14 @@ public:
|
||||
using reference = std::add_lvalue_reference_t<value_type>;
|
||||
using const_reference = std::add_lvalue_reference_t<std::add_const_t<value_type>>;
|
||||
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<size_t>(cur) < static_cast<size_t>(m_bound) ? cur + last : -1;
|
||||
}
|
||||
|
||||
|
||||
size_t totalSize() const _NOEXCEPT {
|
||||
return m_bound;
|
||||
}
|
||||
|
||||
|
||||
SizeType elementNum() const _NOEXCEPT {
|
||||
return static_cast<SizeType>(totalSize() / this->Base::totalSize());
|
||||
}
|
||||
@ -712,20 +712,20 @@ namespace details
|
||||
|
||||
template <size_t Rank, typename SourceType, typename TargetType>
|
||||
auto helpBoundsRangeConvertible(SourceType, TargetType, ...) -> std::false_type;
|
||||
|
||||
|
||||
template <typename SourceType, typename TargetType, size_t Rank>
|
||||
struct BoundsRangeConvertible2 : decltype(helpBoundsRangeConvertible<Rank - 1>(SourceType(), TargetType(),
|
||||
std::integral_constant<bool, SourceType::Depth == TargetType::Depth
|
||||
&& (SourceType::CurrentRange == TargetType::CurrentRange || TargetType::CurrentRange == dynamic_range || SourceType::CurrentRange == dynamic_range)>()))
|
||||
struct BoundsRangeConvertible2 : decltype(helpBoundsRangeConvertible<Rank - 1>(SourceType(), TargetType(),
|
||||
std::integral_constant<bool, SourceType::Depth == TargetType::Depth
|
||||
&& (SourceType::CurrentRange == TargetType::CurrentRange || TargetType::CurrentRange == dynamic_range || SourceType::CurrentRange == dynamic_range)>()))
|
||||
{};
|
||||
|
||||
template <typename SourceType, typename TargetType>
|
||||
struct BoundsRangeConvertible2<SourceType, TargetType, 0> : std::true_type {};
|
||||
|
||||
template <typename SourceType, typename TargetType, size_t Rank = TargetType::Depth>
|
||||
struct BoundsRangeConvertible : decltype(helpBoundsRangeConvertible<Rank - 1>(SourceType(), TargetType(),
|
||||
std::integral_constant<bool, SourceType::Depth == TargetType::Depth
|
||||
&& (!LessThan<size_t(SourceType::CurrentRange), size_t(TargetType::CurrentRange)>::value || TargetType::CurrentRange == dynamic_range || SourceType::CurrentRange == dynamic_range)>()))
|
||||
struct BoundsRangeConvertible : decltype(helpBoundsRangeConvertible<Rank - 1>(SourceType(), TargetType(),
|
||||
std::integral_constant<bool, SourceType::Depth == TargetType::Depth
|
||||
&& (!LessThan<size_t(SourceType::CurrentRange), size_t(TargetType::CurrentRange)>::value || TargetType::CurrentRange == dynamic_range || SourceType::CurrentRange == dynamic_range)>()))
|
||||
{};
|
||||
template <typename SourceType, typename TargetType>
|
||||
struct BoundsRangeConvertible<SourceType, TargetType, 0> : std::true_type {};
|
||||
@ -778,7 +778,7 @@ class static_bounds<SizeType, FirstRange, RestRanges...>
|
||||
|
||||
MyRanges m_ranges;
|
||||
_CONSTEXPR static_bounds(const MyRanges & range) : m_ranges(range) { }
|
||||
|
||||
|
||||
template <typename SizeType2, size_t... Ranges2>
|
||||
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 <typename OtherSizeType, size_t... Ranges, typename Dummy = std::enable_if_t<
|
||||
details::BoundsRangeConvertible<details::BoundsRanges<OtherSizeType, Ranges...>, details::BoundsRanges <SizeType, FirstRange, RestRanges... >>::value>>
|
||||
_CONSTEXPR static_bounds(const static_bounds<OtherSizeType, Ranges...> &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<size_type>::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<size_type>(m_ranges.totalSize());
|
||||
@ -836,12 +836,12 @@ public:
|
||||
{
|
||||
return static_cast<size_type>(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<Dim>().elementNum();
|
||||
}
|
||||
|
||||
|
||||
_CONSTEXPR index_type index_bounds() const _NOEXCEPT
|
||||
{
|
||||
index_type extents;
|
||||
m_ranges.serialize(extents);
|
||||
return extents;
|
||||
}
|
||||
|
||||
|
||||
template <typename OtherSizeTypes, size_t... Ranges>
|
||||
_CONSTEXPR bool operator == (const static_bounds<OtherSizeTypes, Ranges...> & rhs) const _NOEXCEPT
|
||||
{
|
||||
return this->size() == rhs.size();
|
||||
}
|
||||
|
||||
|
||||
template <typename OtherSizeTypes, size_t... Ranges>
|
||||
_CONSTEXPR bool operator != (const static_bounds<OtherSizeTypes, Ranges...> & 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 <typename OtherSizeType>
|
||||
_CONSTEXPR strided_bounds(const strided_bounds<rank, OtherSizeType> &other)
|
||||
_CONSTEXPR strided_bounds(const strided_bounds<rank, OtherSizeType> &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<BoundsType>(totalSize, std::integral_constant<bool, BoundsType::dynamic_rank == 1>());
|
||||
}
|
||||
|
||||
|
||||
struct Sep{};
|
||||
|
||||
|
||||
template <typename T, typename... Args>
|
||||
T static_as_array_view_helper(Sep, Args... args)
|
||||
{
|
||||
@ -1640,7 +1640,7 @@ struct array_view_options
|
||||
};
|
||||
|
||||
template <typename ValueTypeOpt, size_t FirstDimension, size_t... RestDimensions>
|
||||
class array_view : public basic_array_view<typename details::ArrayViewTypeTraits<ValueTypeOpt>::value_type,
|
||||
class array_view : public basic_array_view<typename details::ArrayViewTypeTraits<ValueTypeOpt>::value_type,
|
||||
static_bounds<typename details::ArrayViewTypeTraits<ValueTypeOpt>::size_type, FirstDimension, RestDimensions...>>
|
||||
{
|
||||
template <typename ValueTypeOpt2, size_t FirstDimension2, size_t... RestDimensions2>
|
||||
@ -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 <typename Ptr,
|
||||
typename Dummy = std::enable_if_t<std::is_convertible<Ptr, pointer>::value
|
||||
&& details::LessThan<Base::bounds_type::dynamic_rank, 2>::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<rank, size_type> {extents, details::make_stride(Base::bounds())} };
|
||||
}
|
||||
|
||||
|
||||
_CONSTEXPR reference operator[](const index_type& idx) const
|
||||
{
|
||||
return Base::operator[](idx);
|
||||
}
|
||||
|
||||
|
||||
template <bool Enabled = (rank > 1), typename Dummy = std::enable_if_t<Enabled>>
|
||||
_CONSTEXPR array_view<ValueTypeOpt, RestDimensions...> 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<size_type N>
|
||||
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 <typename OtherValueTypeOpt,
|
||||
typename BaseType = basic_array_view<typename details::ArrayViewTypeTraits<ValueTypeOpt>::value_type, strided_bounds<Rank, typename details::ArrayViewTypeTraits<ValueTypeOpt>::size_type>>,
|
||||
|
Loading…
Reference in New Issue
Block a user