From 787e7ef616c7fec78d687324168c8d84d5349d37 Mon Sep 17 00:00:00 2001 From: B1Z0N Date: Sun, 1 Sep 2019 00:35:04 +0300 Subject: [PATCH 01/14] Thanks to @stayprivates fixed out of bounds access in "TestNotNullostream" --- tests/notnull_tests.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/notnull_tests.cpp b/tests/notnull_tests.cpp index ce5a123..010dd00 100644 --- a/tests/notnull_tests.cpp +++ b/tests/notnull_tests.cpp @@ -234,8 +234,8 @@ void ostream_helper(T v) { std::ostringstream os; std::ostringstream ref; - os << p; - ref << &v; + os << static_cast(p); + ref << static_cast(&v); CHECK(os.str() == ref.str()); } { From d5382a293b9d7cd9e3ec87cc04f388188d38c838 Mon Sep 17 00:00:00 2001 From: B1Z0N Date: Sun, 1 Sep 2019 00:36:13 +0300 Subject: [PATCH 02/14] Fixed memory leaks --- tests/multi_span_tests.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/multi_span_tests.cpp b/tests/multi_span_tests.cpp index 7e3ec89..17188be 100644 --- a/tests/multi_span_tests.cpp +++ b/tests/multi_span_tests.cpp @@ -1220,6 +1220,8 @@ TEST_CASE("md_access") expected += 3; } } + + delete[] image_ptr; } GSL_SUPPRESS(con.4) // NO-FORMAT: attribute @@ -1616,6 +1618,8 @@ TEST_CASE("span_structure_size") multi_span av2 = as_multi_span(av1, dim(5), dim<6>(), dim<4>()); (void) av2; + + delete[] arr; } GSL_SUPPRESS(con.4) // NO-FORMAT: attribute From 23066c829f227ca75cf44f7d727230fcdb7ccc8a Mon Sep 17 00:00:00 2001 From: "Jordan Maples [MSFT]" <49793787+JordanMaples@users.noreply.github.com> Date: Wed, 4 Sep 2019 15:10:14 -0700 Subject: [PATCH 03/14] Update README.md --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 183553f..df9fcb8 100644 --- a/README.md +++ b/README.md @@ -36,6 +36,8 @@ The test suite that exercises GSL has been built and passes successfully on the * GNU/Linux using Clang/LLVM 6.0 * GNU/Linux using Clang/LLVM 7.0 * GNU/Linux using GCC 5.1 +* OS X Mojave 10.14.4 using Apple LLVM version 10.0.0 (10.0.1.10010046) +* OS X Mojave 10.14.3 using Apple LLVM version 10.0.0 (clang-1000.11.45.5) * OS X Yosemite using Xcode with Apple Clang 7.0.0.7000072 * OS X Yosemite using GCC-5.2.0 * OS X Sierra 10.12.4 using Apple LLVM version 8.1.0 (Clang-802.0.42) From bbeb0bdc91f404aa7758668ac788f91696fb2cd8 Mon Sep 17 00:00:00 2001 From: Jordan Maples Date: Sat, 28 Sep 2019 12:54:18 -0700 Subject: [PATCH 04/14] initial deprecation of multi_span and strided_span --- include/gsl/multi_span | 229 +++++++++++++++-------------------- tests/bounds_tests.cpp | 2 +- tests/multi_span_tests.cpp | 2 +- tests/strided_span_tests.cpp | 2 +- 4 files changed, 103 insertions(+), 132 deletions(-) diff --git a/include/gsl/multi_span b/include/gsl/multi_span index 0c1506e..d705978 100644 --- a/include/gsl/multi_span +++ b/include/gsl/multi_span @@ -49,13 +49,14 @@ #pragma warning(disable : 26473) // in some instantiations we cast to the same type #pragma warning(disable : 26490) // TODO: bug in parser - attributes and templates #pragma warning(disable : 26465) // TODO: bug - suppression does not work on template functions +#pragma warning(disable : 4996) // use of function or classes marked [[deprecated]] #if _MSC_VER < 1910 #pragma push_macro("constexpr") #define constexpr /*constexpr*/ -#endif // _MSC_VER < 1910 -#endif // _MSC_VER +#endif // _MSC_VER < 1910 +#endif // _MSC_VER // GCC 7 does not like the signed unsigned missmatch (size_t ptrdiff_t) // While there is a conversion from signed to unsigned, it happens at @@ -95,8 +96,7 @@ namespace details } // namespace details template -class multi_span_index final -{ +class [[deprecated]] multi_span_index final { static_assert(Rank > 0, "Rank must be greater than 0!"); template @@ -111,7 +111,7 @@ public: constexpr multi_span_index() noexcept {} - constexpr multi_span_index(const value_type (&values)[Rank]) noexcept + constexpr multi_span_index(const value_type(&values)[Rank]) noexcept { GSL_SUPPRESS(bounds.1) // NO-FORMAT: attribute GSL_SUPPRESS(bounds.3) // NO-FORMAT: attribute @@ -139,7 +139,7 @@ public: // Preconditions: component_idx < rank GSL_SUPPRESS(bounds.2) // NO-FORMAT: attribute GSL_SUPPRESS(bounds.4) // NO-FORMAT: attribute - constexpr const_reference operator[](std::size_t component_idx) const + constexpr const_reference operator[](std::size_t component_idx) const { Expects(component_idx < Rank); // Component index must be less than rank return elems[component_idx]; @@ -152,10 +152,7 @@ public: return std::equal(elems, elems + rank, rhs.elems); } - constexpr bool operator!=(const multi_span_index& rhs) const - { - return !(*this == rhs); - } + constexpr bool operator!=(const multi_span_index& rhs) const { return !(*this == rhs); } constexpr multi_span_index operator+() const noexcept { return *this; } @@ -184,8 +181,7 @@ public: { GSL_SUPPRESS(bounds.1) // NO-FORMAT: attribute GSL_SUPPRESS(bounds.3) // NO-FORMAT: attribute - std::transform(elems, elems + rank, rhs.elems, elems, - std::plus{}); + std::transform(elems, elems + rank, rhs.elems, elems, std::plus{}); return *this; } @@ -240,7 +236,7 @@ private: #if !defined(_MSC_VER) || _MSC_VER >= 1910 -struct static_bounds_dynamic_range_t +struct [[deprecated]] static_bounds_dynamic_range_t { template ::value>> constexpr operator T() const noexcept @@ -288,12 +284,10 @@ constexpr static_bounds_dynamic_range_t dynamic_range{}; const std::ptrdiff_t dynamic_range = -1; #endif -struct generalized_mapping_tag -{ -}; -struct contiguous_mapping_tag : generalized_mapping_tag +struct [[deprecated]] generalized_mapping_tag { }; +struct[[deprecated]] contiguous_mapping_tag : generalized_mapping_tag{}; namespace details { @@ -305,8 +299,7 @@ namespace details }; template - struct BoundsRanges - { + struct [[deprecated]] BoundsRanges { using size_type = std::ptrdiff_t; static const size_type Depth = 0; static const size_type DynamicNum = 0; @@ -345,7 +338,7 @@ namespace details }; template - struct BoundsRanges : BoundsRanges + struct[[deprecated]] BoundsRanges : BoundsRanges { using Base = BoundsRanges; using size_type = std::ptrdiff_t; @@ -358,8 +351,9 @@ namespace details size_type m_bound; public: - GSL_SUPPRESS(f.23) // NO-FORMAT: attribute // this pointer type is cannot be assigned nullptr - issue in not_null - GSL_SUPPRESS(bounds.1) // NO-FORMAT: attribute + GSL_SUPPRESS( + f.23) // NO-FORMAT: attribute // this pointer type is cannot be assigned nullptr - issue in not_null + GSL_SUPPRESS(bounds.1) // NO-FORMAT: attribute constexpr BoundsRanges(const std::ptrdiff_t* const arr) : Base(arr + 1), m_bound(*arr * this->Base::totalSize()) { @@ -370,13 +364,13 @@ namespace details template constexpr BoundsRanges(const BoundsRanges& other, - bool /* firstLevel */ = true) + bool /* firstLevel */ = true) : Base(static_cast&>(other), false) , m_bound(other.totalSize()) {} template - constexpr void serialize(T& arr) const + constexpr void serialize(T & arr) const { arr[Dim] = elementNum(); this->Base::template serialize(arr); @@ -400,19 +394,19 @@ namespace details return cur < m_bound ? cur + last : -1; } - GSL_SUPPRESS(c.128) // NO-FORMAT: attribute // no pointers to BoundsRanges should be ever used - constexpr size_type totalSize() const noexcept - { - return m_bound; - } + GSL_SUPPRESS( + c.128) // NO-FORMAT: attribute // no pointers to BoundsRanges should be ever used + constexpr size_type totalSize() const noexcept { return m_bound; } - GSL_SUPPRESS(c.128) // NO-FORMAT: attribute // no pointers to BoundsRanges should be ever used + GSL_SUPPRESS( + c.128) // NO-FORMAT: attribute // no pointers to BoundsRanges should be ever used constexpr size_type elementNum() const noexcept { return totalSize() / this->Base::totalSize(); } - GSL_SUPPRESS(c.128) // NO-FORMAT: attribute // no pointers to BoundsRanges should be ever used + GSL_SUPPRESS( + c.128) // NO-FORMAT: attribute // no pointers to BoundsRanges should be ever used constexpr size_type elementNum(std::size_t dim) const noexcept { if (dim > 0) @@ -429,7 +423,7 @@ namespace details }; template - struct BoundsRanges : BoundsRanges + struct[[deprecated]] BoundsRanges : BoundsRanges { using Base = BoundsRanges; using size_type = std::ptrdiff_t; @@ -444,7 +438,7 @@ namespace details template constexpr BoundsRanges(const BoundsRanges& other, - bool firstLevel = true) + bool firstLevel = true) : Base(static_cast&>(other), false) { GSL_SUPPRESS(type.4) // NO-FORMAT: attribute // TODO: false positive @@ -452,7 +446,7 @@ namespace details } template - constexpr void serialize(T& arr) const + constexpr void serialize(T & arr) const { arr[Dim] = elementNum(); this->Base::template serialize(arr); @@ -461,12 +455,11 @@ namespace details template constexpr size_type linearize(const T& arr) const { - GSL_SUPPRESS(bounds.4) // NO-FORMAT: attribute + GSL_SUPPRESS(bounds.4) // NO-FORMAT: attribute Expects(arr[Dim] >= 0 && arr[Dim] < CurrentRange); // Index is out of range - GSL_SUPPRESS(bounds.4) // NO-FORMAT: attribute + GSL_SUPPRESS(bounds.4) // NO-FORMAT: attribute const ptrdiff_t d = arr[Dim]; - return this->Base::totalSize() * d + - this->Base::template linearize(arr); + return this->Base::totalSize() * d + this->Base::template linearize(arr); } template @@ -478,19 +471,19 @@ namespace details return this->Base::totalSize() * arr[Dim] + last; } - GSL_SUPPRESS(c.128) // NO-FORMAT: attribute // no pointers to BoundsRanges should be ever used + GSL_SUPPRESS( + c.128) // NO-FORMAT: attribute // no pointers to BoundsRanges should be ever used constexpr size_type totalSize() const noexcept { return CurrentRange * this->Base::totalSize(); } - GSL_SUPPRESS(c.128) // NO-FORMAT: attribute // no pointers to BoundsRanges should be ever used - constexpr size_type elementNum() const noexcept - { - return CurrentRange; - } + GSL_SUPPRESS( + c.128) // NO-FORMAT: attribute // no pointers to BoundsRanges should be ever used + constexpr size_type elementNum() const noexcept { return CurrentRange; } - GSL_SUPPRESS(c.128) // NO-FORMAT: attribute // no pointers to BoundsRanges should be ever used + GSL_SUPPRESS( + c.128) // NO-FORMAT: attribute // no pointers to BoundsRanges should be ever used constexpr size_type elementNum(std::size_t dim) const noexcept { if (dim > 0) @@ -506,17 +499,14 @@ namespace details }; template - struct BoundsRangeConvertible + struct[[deprecated]] BoundsRangeConvertible : public std::integral_constant= TargetType::TotalSize || TargetType::TotalSize == dynamic_range || SourceType::TotalSize == dynamic_range || - TargetType::TotalSize == 0)> - { - }; + TargetType::TotalSize == 0)>{}; template - struct TypeListIndexer - { + struct [[deprecated]] TypeListIndexer { const TypeChain& obj_; constexpr TypeListIndexer(const TypeChain& obj) : obj_(obj) {} @@ -529,13 +519,13 @@ namespace details template constexpr auto getObj(std::false_type) - -> decltype(TypeListIndexer(static_cast(obj_)).template get()) + ->decltype(TypeListIndexer(static_cast(obj_)).template get()) { return TypeListIndexer(static_cast(obj_)).template get(); } template - constexpr auto get() -> decltype(getObj(std::integral_constant())) + constexpr auto get()->decltype(getObj(std::integral_constant())) { return getObj(std::integral_constant()); } @@ -555,7 +545,7 @@ namespace details for (std::size_t i = 0; i < Rank - 1; ++i) { GSL_SUPPRESS(bounds.4) // NO-FORMAT: attribute - ret[i] = other[i + 1]; + ret[i] = other[i + 1]; } return ret; } @@ -565,14 +555,13 @@ template class bounds_iterator; template -class static_bounds -{ +class [[deprecated]] static_bounds { public: static_bounds(const details::BoundsRanges&) {} }; template -class static_bounds +class[[deprecated]] static_bounds { using MyRanges = details::BoundsRanges; @@ -604,10 +593,10 @@ public: template > - static auto helpBoundsRangeConvertible(SourceType, TargetType, std::true_type) -> Ret; + static auto helpBoundsRangeConvertible(SourceType, TargetType, std::true_type)->Ret; template - static auto helpBoundsRangeConvertible(SourceType, TargetType, ...) -> std::false_type; + static auto helpBoundsRangeConvertible(SourceType, TargetType, ...)->std::false_type; template struct BoundsRangeConvertible2 @@ -724,10 +713,7 @@ public: return !(*this == rhs); } - constexpr const_iterator begin() const noexcept - { - return const_iterator(*this, index_type{}); - } + constexpr const_iterator begin() const noexcept { return const_iterator(*this, index_type{}); } constexpr const_iterator end() const noexcept { @@ -736,7 +722,7 @@ public: }; template -class strided_bounds { +class [[deprecated]] strided_bounds { template friend class strided_bounds; @@ -760,14 +746,13 @@ public: constexpr strided_bounds& operator=(const strided_bounds&) noexcept = default; - constexpr strided_bounds(const value_type (&values)[rank], index_type strides) + constexpr strided_bounds(const value_type(&values)[rank], index_type strides) : m_extents(values), m_strides(std::move(strides)) {} constexpr strided_bounds(const index_type& extents, const index_type& strides) noexcept : m_extents(extents), m_strides(strides) - { - } + {} constexpr index_type strides() const noexcept { return m_strides; } @@ -839,21 +824,14 @@ private: }; template -struct is_bounds : std::integral_constant -{ -}; +struct[[deprecated]] is_bounds : std::integral_constant{}; template -struct is_bounds> : std::integral_constant -{ -}; +struct[[deprecated]] is_bounds> : std::integral_constant{}; template -struct is_bounds> : std::integral_constant -{ -}; +struct[[deprecated]] is_bounds> : std::integral_constant{}; template -class bounds_iterator -{ +class [[deprecated]] bounds_iterator { public: static const std::size_t rank = IndexType::rank; using iterator_category = std::random_access_iterator_tag; @@ -974,7 +952,6 @@ public: return curr_ == rhs.curr_; } - constexpr bool operator!=(const bounds_iterator& rhs) const noexcept { return !(*this == rhs); } constexpr bool operator<(const bounds_iterator& rhs) const noexcept @@ -988,16 +965,15 @@ public: constexpr bool operator>=(const bounds_iterator& rhs) const noexcept { return !(rhs > *this); } - void swap(bounds_iterator& rhs) noexcept + void swap(bounds_iterator & rhs) noexcept { std::swap(boundary_, rhs.boundary_); std::swap(curr_, rhs.curr_); } private: - GSL_SUPPRESS(bounds.4) // NO-FORMAT: attribute - constexpr bool less(index_type& one, index_type& other) const noexcept + constexpr bool less(index_type & one, index_type & other) const noexcept { for (std::size_t i = 0; i < rank; ++i) { @@ -1228,8 +1204,7 @@ namespace details } // namespace details template -class multi_span -{ +class [[deprecated("This concept is not present in the C++ Core Guidelines")]] multi_span { // TODO do we still need this? template @@ -1262,8 +1237,7 @@ private: public: // default constructor - same as constructing from nullptr_t GSL_SUPPRESS(type.6) // NO-FORMAT: attribute // TODO: false positive - constexpr multi_span() noexcept - : multi_span(nullptr, bounds_type{}) + constexpr multi_span() noexcept : multi_span(nullptr, bounds_type{}) { static_assert(bounds_type::dynamic_rank != 0 || (bounds_type::dynamic_rank == 0 && bounds_type::static_size == 0), @@ -1273,8 +1247,7 @@ public: // construct from nullptr - get an empty multi_span GSL_SUPPRESS(type.6) // NO-FORMAT: attribute // TODO: false positive - constexpr multi_span(std::nullptr_t) noexcept - : multi_span(nullptr, bounds_type{}) + constexpr multi_span(std::nullptr_t) noexcept : multi_span(nullptr, bounds_type{}) { static_assert(bounds_type::dynamic_rank != 0 || (bounds_type::dynamic_rank == 0 && bounds_type::static_size == 0), @@ -1298,8 +1271,7 @@ public: // construct from a single element GSL_SUPPRESS(type.6) // NO-FORMAT: attribute // TODO: false positive - constexpr multi_span(reference data) noexcept - : multi_span(&data, bounds_type{1}) + constexpr multi_span(reference data) noexcept : multi_span(&data, bounds_type{1}) { static_assert(bounds_type::dynamic_rank > 0 || bounds_type::static_size == 0 || bounds_type::static_size == 1, @@ -1308,17 +1280,14 @@ public: } // prevent constructing from temporaries for single-elements - constexpr multi_span(value_type&&) = delete; + constexpr multi_span(value_type &&) = delete; // construct from pointer + length GSL_SUPPRESS(type.6) // NO-FORMAT: attribute // TODO: false positive - constexpr multi_span(pointer ptr, size_type size) - : multi_span(ptr, bounds_type{size}) - {} + constexpr multi_span(pointer ptr, size_type size) : multi_span(ptr, bounds_type{size}) {} // construct from pointer + length - multidimensional - constexpr multi_span(pointer data, bounds_type bounds) - : data_(data), bounds_(std::move(bounds)) + constexpr multi_span(pointer data, bounds_type bounds) : data_(data), bounds_(std::move(bounds)) { Expects((bounds_.size() > 0 && data != nullptr) || bounds_.size() == 0); } @@ -1336,7 +1305,7 @@ public: // construct from n-dimensions static array template > - constexpr multi_span(T (&arr)[N]) + constexpr multi_span(T(&arr)[N]) : multi_span(reinterpret_cast(arr), bounds_type{typename Helper::bounds_type{}}) { static_assert(std::is_convertible::value, @@ -1357,7 +1326,7 @@ public: // construct from std::array template - constexpr multi_span(std::array& arr) + constexpr multi_span(std::array & arr) : multi_span(arr.data(), bounds_type{static_bounds{}}) { static_assert( @@ -1381,7 +1350,7 @@ public: // prevent constructing from temporary std::array template - constexpr multi_span(std::array&& arr) = delete; + constexpr multi_span(std::array && arr) = delete; // construct from containers // future: could use contiguous_iterator_traits to identify only contiguous containers @@ -1389,11 +1358,11 @@ public: template ::value && - std::is_convertible::value && + std::is_convertible::value && std::is_same().size(), *std::declval().data())>, DataType>::value>> - constexpr multi_span(Cont& cont) + constexpr multi_span(Cont & cont) : multi_span(static_cast(cont.data()), details::newBoundsHelper(narrow_cast(cont.size()))) {} @@ -1402,11 +1371,11 @@ public: template ::value && - std::is_convertible::value && + std::is_convertible::value && std::is_same().size(), *std::declval().data())>, DataType>::value>> - explicit constexpr multi_span(Cont&& cont) = delete; + explicit constexpr multi_span(Cont && cont) = delete; // construct from a convertible multi_span template section(index_type origin, - index_type extents) const + constexpr strided_span section(index_type origin, index_type extents) const { const size_type size = this->bounds().total_size() - this->bounds().linearize(origin); return {&this->operator[](origin), size, @@ -1636,8 +1604,8 @@ public: template , std::remove_cv_t>::value>> - constexpr bool operator>(const multi_span& other) const - noexcept + constexpr bool operator>(const multi_span& other) + const noexcept { return (other < *this); } @@ -1659,7 +1627,7 @@ public: // DimCount and Enabled here are workarounds for a bug in MSVC 2015 template 0), typename = std::enable_if_t> -constexpr auto as_multi_span(SpanType s, Dimensions2... dims) +[[deprecated]] constexpr auto as_multi_span(SpanType s, Dimensions2... dims) -> multi_span { static_assert(details::is_multi_span::value, @@ -1673,7 +1641,8 @@ constexpr auto as_multi_span(SpanType s, Dimensions2... dims) // convert a multi_span to a multi_span template -multi_span as_bytes(multi_span s) noexcept +[[deprecated]] multi_span +as_bytes(multi_span s) noexcept { static_assert(std::is_trivial>::value, "The value_type of multi_span must be a trivial type."); @@ -1685,7 +1654,7 @@ multi_span as_bytes(multi_span s) n // on all implementations. It should be considered an experimental extension // to the standard GSL interface. template -multi_span as_writeable_bytes(multi_span s) noexcept +[[deprecated]] multi_span as_writeable_bytes(multi_span s) noexcept { static_assert(std::is_trivial>::value, "The value_type of multi_span must be a trivial type."); @@ -1697,7 +1666,7 @@ multi_span as_writeable_bytes(multi_span s) noexcept // on all implementations. It should be considered an experimental extension // to the standard GSL interface. template -constexpr auto as_multi_span(multi_span s) -> multi_span< +[[deprecated]] constexpr auto as_multi_span(multi_span s) -> multi_span< const U, static_cast( multi_span::bounds_type::static_size != dynamic_range ? (static_cast( @@ -1723,7 +1692,7 @@ constexpr auto as_multi_span(multi_span s) -> multi_s // on all implementations. It should be considered an experimental extension // to the standard GSL interface. template -constexpr auto as_multi_span(multi_span s) +[[deprecated]] constexpr auto as_multi_span(multi_span s) -> multi_span( multi_span::bounds_type::static_size != dynamic_range ? static_cast( @@ -1743,7 +1712,7 @@ constexpr auto as_multi_span(multi_span s) } template -constexpr auto as_multi_span(T* const& ptr, dim_t... args) +[[deprecated]] constexpr auto as_multi_span(T* const& ptr, dim_t... args) -> multi_span, Dimensions...> { return {reinterpret_cast*>(ptr), @@ -1752,41 +1721,42 @@ constexpr auto as_multi_span(T* const& ptr, dim_t... args) } template -constexpr auto as_multi_span(T* arr, std::ptrdiff_t len) -> +[[deprecated]] constexpr auto as_multi_span(T* arr, std::ptrdiff_t len) -> typename details::SpanArrayTraits::type { return {reinterpret_cast*>(arr), len}; } template -constexpr auto as_multi_span(T (&arr)[N]) -> typename details::SpanArrayTraits::type +[[deprecated]] constexpr auto as_multi_span(T (&arr)[N]) -> + typename details::SpanArrayTraits::type { return {arr}; } template -constexpr multi_span as_multi_span(const std::array& arr) +[[deprecated]] constexpr multi_span as_multi_span(const std::array& arr) { return {arr}; } template -constexpr multi_span as_multi_span(const std::array&&) = delete; +[[deprecated]] constexpr multi_span as_multi_span(const std::array&&) = delete; template -constexpr multi_span as_multi_span(std::array& arr) +[[deprecated]] constexpr multi_span as_multi_span(std::array& arr) { return {arr}; } template -constexpr multi_span as_multi_span(T* begin, T* end) +[[deprecated]] constexpr multi_span as_multi_span(T* begin, T* end) { return {begin, end}; } template -constexpr auto as_multi_span(Cont& arr) -> std::enable_if_t< +[[deprecated]] constexpr auto as_multi_span(Cont& arr) -> std::enable_if_t< !details::is_multi_span>::value, multi_span, dynamic_range>> { @@ -1795,14 +1765,14 @@ constexpr auto as_multi_span(Cont& arr) -> std::enable_if_t< } template -constexpr auto as_multi_span(Cont&& arr) -> std::enable_if_t< +[[deprecated]] constexpr auto as_multi_span(Cont&& arr) -> std::enable_if_t< !details::is_multi_span>::value, multi_span, dynamic_range>> = delete; // from basic_string which doesn't have nonconst .data() member like other contiguous containers template GSL_SUPPRESS(bounds.4) // NO-FORMAT: attribute -constexpr auto as_multi_span(std::basic_string& str) +[[deprecated]] constexpr auto as_multi_span(std::basic_string& str) -> multi_span { Expects(str.size() < PTRDIFF_MAX); @@ -2055,8 +2025,7 @@ private: }; template -class contiguous_span_iterator -{ +class [[deprecated]] contiguous_span_iterator { public: using iterator_category = std::random_access_iterator_tag; using value_type = typename Span::value_type; @@ -2072,7 +2041,8 @@ private: const Span* m_validator; GSL_SUPPRESS(bounds.1) // NO-FORMAT: attribute - void validateThis() const { + void validateThis() const + { // iterator is out of range of the array Expects(data_ >= m_validator->data_ && data_ < m_validator->data_ + m_validator->size()); } @@ -2161,7 +2131,7 @@ public: bool operator>(const contiguous_span_iterator& rhs) const { return rhs < *this; } bool operator>=(const contiguous_span_iterator& rhs) const { return !(rhs > *this); } - void swap(contiguous_span_iterator& rhs) noexcept + void swap(contiguous_span_iterator & rhs) noexcept { std::swap(data_, rhs.data_); std::swap(m_validator, rhs.m_validator); @@ -2176,7 +2146,8 @@ contiguous_span_iterator operator+(typename contiguous_span_iterator } template -class general_span_iterator { +class [[deprecated( + "This concept is not present in the C++ Core Guidelines")]] general_span_iterator { public: using iterator_category = std::random_access_iterator_tag; using value_type = typename Span::value_type; @@ -2259,7 +2230,7 @@ public: bool operator<=(const general_span_iterator& rhs) const { return !(rhs < *this); } bool operator>(const general_span_iterator& rhs) const { return rhs < *this; } bool operator>=(const general_span_iterator& rhs) const { return !(rhs > *this); } - void swap(general_span_iterator& rhs) noexcept + void swap(general_span_iterator & rhs) noexcept { std::swap(m_itr, rhs.m_itr); std::swap(m_container, rhs.m_container); diff --git a/tests/bounds_tests.cpp b/tests/bounds_tests.cpp index e586d44..1de4e1a 100644 --- a/tests/bounds_tests.cpp +++ b/tests/bounds_tests.cpp @@ -17,7 +17,7 @@ #ifdef _MSC_VER // blanket turn off warnings from CppCoreCheck from catch // so people aren't annoyed by them when running the tool. -#pragma warning(disable : 26440 26426) // from catch +#pragma warning(disable : 26440 26426 4996) // from catch deprecated #endif #include // for AssertionHandler, StringRef, TEST_CASE diff --git a/tests/multi_span_tests.cpp b/tests/multi_span_tests.cpp index 7e3ec89..3aaf2f9 100644 --- a/tests/multi_span_tests.cpp +++ b/tests/multi_span_tests.cpp @@ -17,7 +17,7 @@ #ifdef _MSC_VER // blanket turn off warnings from CppCoreCheck from catch // so people aren't annoyed by them when running the tool. -#pragma warning(disable : 26440 26426) // from catch +#pragma warning(disable : 26440 26426 4996) // from catch deprecated #endif diff --git a/tests/strided_span_tests.cpp b/tests/strided_span_tests.cpp index 1563d90..949b1c2 100644 --- a/tests/strided_span_tests.cpp +++ b/tests/strided_span_tests.cpp @@ -17,7 +17,7 @@ #ifdef _MSC_VER // blanket turn off warnings from CppCoreCheck from catch // so people aren't annoyed by them when running the tool. -#pragma warning(disable : 26440 26426) // from catch +#pragma warning(disable : 26440 26426 4996) // from catch deprecated #endif From e026971c03ea0495f9623d9aad7a9beca24b5692 Mon Sep 17 00:00:00 2001 From: Jordan Maples Date: Wed, 2 Oct 2019 15:40:15 -0700 Subject: [PATCH 05/14] deprecation, removing cassert --- include/gsl/multi_span | 1 - 1 file changed, 1 deletion(-) diff --git a/include/gsl/multi_span b/include/gsl/multi_span index d705978..e67b811 100644 --- a/include/gsl/multi_span +++ b/include/gsl/multi_span @@ -23,7 +23,6 @@ #include // for transform, lexicographical_compare #include // for array -#include #include // for ptrdiff_t, size_t, nullptr_t #include // for PTRDIFF_MAX #include // for divides, multiplies, minus, negate, plus From b630dfe36aeb31f8cd7fe4ec538af6bae8aa2f8e Mon Sep 17 00:00:00 2001 From: Jordan Maples Date: Wed, 2 Oct 2019 15:42:40 -0700 Subject: [PATCH 06/14] Guideline -> Guidelines fixing issue as reported in issue #746 --- CONTRIBUTING.md | 4 ++-- ThirdPartyNotices.txt | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 10e6c32..990b8e1 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,6 +1,6 @@ -## Contributing to the Guideline Support Library +## Contributing to the Guidelines Support Library -The Guideline Support Library (GSL) contains functions and types that are suggested for use by the +The Guidelines Support Library (GSL) contains functions and types that are suggested for use by the [C++ Core Guidelines](https://github.com/isocpp/CppCoreGuidelines). GSL design changes are made only as a result of modifications to the Guidelines. GSL is accepting contributions that improve or refine any of the types in this library as well as ports to other platforms. Changes should have an issue diff --git a/ThirdPartyNotices.txt b/ThirdPartyNotices.txt index 94b9acc..ebf7b6e 100644 --- a/ThirdPartyNotices.txt +++ b/ThirdPartyNotices.txt @@ -2,7 +2,7 @@ THIRD-PARTY SOFTWARE NOTICES AND INFORMATION Do Not Translate or Localize -GSL: Guideline Support Library incorporates third party material from the projects listed below. The original copyright notice and the license under which Microsoft received such third party material are set forth below. Microsoft reserves all other rights not expressly granted, whether by implication, estoppel or otherwise. +GSL: Guidelines Support Library incorporates third party material from the projects listed below. The original copyright notice and the license under which Microsoft received such third party material are set forth below. Microsoft reserves all other rights not expressly granted, whether by implication, estoppel or otherwise. 1. Catch (https://github.com/philsquared/Catch) From eb995b36714c6c8639da25ea90f8f4f73017e8ca Mon Sep 17 00:00:00 2001 From: Jordan Maples Date: Wed, 2 Oct 2019 16:17:46 -0700 Subject: [PATCH 07/14] deprecating strided_span --- include/gsl/multi_span | 2 +- tests/bounds_tests.cpp | 4 +++- tests/multi_span_tests.cpp | 4 +++- tests/strided_span_tests.cpp | 4 +++- 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/include/gsl/multi_span b/include/gsl/multi_span index e67b811..eac4397 100644 --- a/include/gsl/multi_span +++ b/include/gsl/multi_span @@ -1781,7 +1781,7 @@ GSL_SUPPRESS(bounds.4) // NO-FORMAT: attribute // strided_span is an extension that is not strictly part of the GSL at this time. // It is kept here while the multidimensional interface is still being defined. template -class strided_span +class [[deprecated]] strided_span { public: using bounds_type = strided_bounds; diff --git a/tests/bounds_tests.cpp b/tests/bounds_tests.cpp index 1de4e1a..29c198a 100644 --- a/tests/bounds_tests.cpp +++ b/tests/bounds_tests.cpp @@ -17,7 +17,9 @@ #ifdef _MSC_VER // blanket turn off warnings from CppCoreCheck from catch // so people aren't annoyed by them when running the tool. -#pragma warning(disable : 26440 26426 4996) // from catch deprecated +#pragma warning(disable : 26440 26426) // from catch +#pragma warning(disable : 4996) // use of function or classes marked [[deprecated]] + #endif #include // for AssertionHandler, StringRef, TEST_CASE diff --git a/tests/multi_span_tests.cpp b/tests/multi_span_tests.cpp index 3aaf2f9..97b2271 100644 --- a/tests/multi_span_tests.cpp +++ b/tests/multi_span_tests.cpp @@ -17,7 +17,9 @@ #ifdef _MSC_VER // blanket turn off warnings from CppCoreCheck from catch // so people aren't annoyed by them when running the tool. -#pragma warning(disable : 26440 26426 4996) // from catch deprecated +#pragma warning(disable : 26440 26426) // from catch +#pragma warning(disable : 4996) // multi_span is in the process of being deprecated. + // Suppressing warnings until it is completely removed #endif diff --git a/tests/strided_span_tests.cpp b/tests/strided_span_tests.cpp index 949b1c2..0d0896a 100644 --- a/tests/strided_span_tests.cpp +++ b/tests/strided_span_tests.cpp @@ -17,7 +17,9 @@ #ifdef _MSC_VER // blanket turn off warnings from CppCoreCheck from catch // so people aren't annoyed by them when running the tool. -#pragma warning(disable : 26440 26426 4996) // from catch deprecated +#pragma warning(disable : 26440 26426) // from catch deprecated +#pragma warning(disable : 4996) // strided_span is in the process of being deprecated. + // Suppressing warnings until it is completely removed #endif From 5e4463a7c19cca78b949d094f1e364bece769485 Mon Sep 17 00:00:00 2001 From: Jordan Maples Date: Thu, 3 Oct 2019 15:47:25 -0700 Subject: [PATCH 08/14] removing function deprecation, adding additional class / struct deprecations --- include/gsl/multi_span | 77 +++++++++++++++++++++--------------------- 1 file changed, 39 insertions(+), 38 deletions(-) diff --git a/include/gsl/multi_span b/include/gsl/multi_span index eac4397..4ea5c83 100644 --- a/include/gsl/multi_span +++ b/include/gsl/multi_span @@ -76,18 +76,18 @@ namespace gsl namespace details { template - struct SizeTypeTraits + struct [[deprecated]] SizeTypeTraits { static const SizeType max_value = std::numeric_limits::max(); }; template - class are_integral : public std::integral_constant + class [[deprecated]] are_integral : public std::integral_constant { }; template - class are_integral + class [[deprecated]] are_integral : public std::integral_constant::value && are_integral::value> { @@ -292,7 +292,7 @@ namespace details { template - struct LessThan + struct [[deprecated]] LessThan { static const bool value = Left < Right; }; @@ -551,7 +551,7 @@ namespace details } // namespace details template -class bounds_iterator; +class [[deprecated]] bounds_iterator; template class [[deprecated]] static_bounds { @@ -1067,17 +1067,17 @@ namespace details } // namespace details template -class contiguous_span_iterator; +class [[deprecated]] contiguous_span_iterator; template -class general_span_iterator; +class [[deprecated]] general_span_iterator; template -struct dim_t +struct [[deprecated]] dim_t { static const std::ptrdiff_t value = DimSize; }; template <> -struct dim_t +struct [[deprecated]] dim_t { static const std::ptrdiff_t value = dynamic_range; const std::ptrdiff_t dvalue; @@ -1098,28 +1098,30 @@ constexpr dim_t dim(std::ptrdiff_t n) noexcept template -class multi_span; +class [[deprecated]] multi_span; + template -class strided_span; +class [[deprecated]] strided_span; namespace details { template - struct SpanTypeTraits + struct [[deprecated]] SpanTypeTraits { using value_type = T; using size_type = std::size_t; }; template - struct SpanTypeTraits::type> + struct [[deprecated]] SpanTypeTraits< + Traits, typename std::is_reference::type> { using value_type = typename Traits::span_traits::value_type; using size_type = typename Traits::span_traits::size_type; }; template - struct SpanArrayTraits + struct [[deprecated]] SpanArrayTraits { using type = multi_span; using value_type = T; @@ -1128,7 +1130,7 @@ namespace details using reference = T&; }; template - struct SpanArrayTraits : SpanArrayTraits + struct [[deprecated]] SpanArrayTraits : SpanArrayTraits { }; @@ -1152,7 +1154,7 @@ namespace details totalSize, std::integral_constant()); } - struct Sep + struct [[deprecated]] Sep { }; @@ -1175,29 +1177,29 @@ namespace details } template - struct static_as_multi_span_static_bounds_helper + struct [[deprecated]] static_as_multi_span_static_bounds_helper { using type = static_bounds<(Dimensions::value)...>; }; template - struct is_multi_span_oracle : std::false_type + struct [[deprecated]] is_multi_span_oracle : std::false_type { }; template - struct is_multi_span_oracle> + struct [[deprecated]] is_multi_span_oracle> : std::true_type { }; template - struct is_multi_span_oracle> : std::true_type + struct [[deprecated]] is_multi_span_oracle> : std::true_type { }; template - struct is_multi_span : is_multi_span_oracle> + struct [[deprecated]] is_multi_span : is_multi_span_oracle> { }; } // namespace details @@ -1626,7 +1628,7 @@ public: // DimCount and Enabled here are workarounds for a bug in MSVC 2015 template 0), typename = std::enable_if_t> -[[deprecated]] constexpr auto as_multi_span(SpanType s, Dimensions2... dims) +constexpr auto as_multi_span(SpanType s, Dimensions2... dims) -> multi_span { static_assert(details::is_multi_span::value, @@ -1640,7 +1642,7 @@ template to a multi_span template -[[deprecated]] multi_span +multi_span as_bytes(multi_span s) noexcept { static_assert(std::is_trivial>::value, @@ -1653,7 +1655,7 @@ as_bytes(multi_span s) noexcept // on all implementations. It should be considered an experimental extension // to the standard GSL interface. template -[[deprecated]] multi_span as_writeable_bytes(multi_span s) noexcept +multi_span as_writeable_bytes(multi_span s) noexcept { static_assert(std::is_trivial>::value, "The value_type of multi_span must be a trivial type."); @@ -1665,7 +1667,7 @@ template // on all implementations. It should be considered an experimental extension // to the standard GSL interface. template -[[deprecated]] constexpr auto as_multi_span(multi_span s) -> multi_span< +constexpr auto as_multi_span(multi_span s) -> multi_span< const U, static_cast( multi_span::bounds_type::static_size != dynamic_range ? (static_cast( @@ -1691,7 +1693,7 @@ template // on all implementations. It should be considered an experimental extension // to the standard GSL interface. template -[[deprecated]] constexpr auto as_multi_span(multi_span s) +constexpr auto as_multi_span(multi_span s) -> multi_span( multi_span::bounds_type::static_size != dynamic_range ? static_cast( @@ -1711,7 +1713,7 @@ template } template -[[deprecated]] constexpr auto as_multi_span(T* const& ptr, dim_t... args) +constexpr auto as_multi_span(T* const& ptr, dim_t... args) -> multi_span, Dimensions...> { return {reinterpret_cast*>(ptr), @@ -1720,42 +1722,42 @@ template } template -[[deprecated]] constexpr auto as_multi_span(T* arr, std::ptrdiff_t len) -> +constexpr auto as_multi_span(T* arr, std::ptrdiff_t len) -> typename details::SpanArrayTraits::type { return {reinterpret_cast*>(arr), len}; } template -[[deprecated]] constexpr auto as_multi_span(T (&arr)[N]) -> +constexpr auto as_multi_span(T (&arr)[N]) -> typename details::SpanArrayTraits::type { return {arr}; } template -[[deprecated]] constexpr multi_span as_multi_span(const std::array& arr) +constexpr multi_span as_multi_span(const std::array& arr) { return {arr}; } template -[[deprecated]] constexpr multi_span as_multi_span(const std::array&&) = delete; +constexpr multi_span as_multi_span(const std::array&&) = delete; template -[[deprecated]] constexpr multi_span as_multi_span(std::array& arr) +constexpr multi_span as_multi_span(std::array& arr) { return {arr}; } template -[[deprecated]] constexpr multi_span as_multi_span(T* begin, T* end) +constexpr multi_span as_multi_span(T* begin, T* end) { return {begin, end}; } template -[[deprecated]] constexpr auto as_multi_span(Cont& arr) -> std::enable_if_t< +constexpr auto as_multi_span(Cont& arr) -> std::enable_if_t< !details::is_multi_span>::value, multi_span, dynamic_range>> { @@ -1764,14 +1766,14 @@ template } template -[[deprecated]] constexpr auto as_multi_span(Cont&& arr) -> std::enable_if_t< +constexpr auto as_multi_span(Cont&& arr) -> std::enable_if_t< !details::is_multi_span>::value, multi_span, dynamic_range>> = delete; // from basic_string which doesn't have nonconst .data() member like other contiguous containers template GSL_SUPPRESS(bounds.4) // NO-FORMAT: attribute -[[deprecated]] constexpr auto as_multi_span(std::basic_string& str) +constexpr auto as_multi_span(std::basic_string& str) -> multi_span { Expects(str.size() < PTRDIFF_MAX); @@ -2145,8 +2147,7 @@ contiguous_span_iterator operator+(typename contiguous_span_iterator } template -class [[deprecated( - "This concept is not present in the C++ Core Guidelines")]] general_span_iterator { +class [[deprecated]] general_span_iterator { public: using iterator_category = std::random_access_iterator_tag; using value_type = typename Span::value_type; From 7adf7eb6fe4c8d90a60df6ba2833b55146f79716 Mon Sep 17 00:00:00 2001 From: Jordan Maples Date: Thu, 3 Oct 2019 17:52:49 -0700 Subject: [PATCH 09/14] new messages --- include/gsl/multi_span | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/include/gsl/multi_span b/include/gsl/multi_span index 4ea5c83..d2b2a69 100644 --- a/include/gsl/multi_span +++ b/include/gsl/multi_span @@ -1098,10 +1098,10 @@ constexpr dim_t dim(std::ptrdiff_t n) noexcept template -class [[deprecated]] multi_span; +class [[deprecated("gsl::multi_span is deprecated because it is not in the C++ Core Guidelines")]] multi_span; template -class [[deprecated]] strided_span; +class [[deprecated("gsl::strided_span is deprecated because it is not in the C++ Core Guidelines")]] strided_span; namespace details { @@ -1205,7 +1205,7 @@ namespace details } // namespace details template -class [[deprecated("This concept is not present in the C++ Core Guidelines")]] multi_span { +class [[deprecated("gsl::multi_span is deprecated because it is not in the C++ Core Guidelines")]] multi_span { // TODO do we still need this? template @@ -1783,7 +1783,7 @@ constexpr auto as_multi_span(std::basic_string& str) // strided_span is an extension that is not strictly part of the GSL at this time. // It is kept here while the multidimensional interface is still being defined. template -class [[deprecated]] strided_span +class [[deprecated("gsl::strided_span is deprecated because it is not in the C++ Core Guidelines")]] strided_span { public: using bounds_type = strided_bounds; From 2b8f7aea325ed2ef193d572599820aad098ebf40 Mon Sep 17 00:00:00 2001 From: Jordan Maples Date: Fri, 4 Oct 2019 12:38:55 -0700 Subject: [PATCH 10/14] adding clang/gcc suppression of the deprecation warnings. --- include/gsl/multi_span | 9 +++++++++ tests/bounds_tests.cpp | 8 ++++++++ tests/multi_span_tests.cpp | 10 +++++++++- tests/strided_span_tests.cpp | 8 ++++++++ 4 files changed, 34 insertions(+), 1 deletion(-) diff --git a/include/gsl/multi_span b/include/gsl/multi_span index d2b2a69..3a2d982 100644 --- a/include/gsl/multi_span +++ b/include/gsl/multi_span @@ -57,6 +57,11 @@ #endif // _MSC_VER < 1910 #endif // _MSC_VER +#if __clang__ || __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wdeprecated-declarations" +#endif + // GCC 7 does not like the signed unsigned missmatch (size_t ptrdiff_t) // While there is a conversion from signed to unsigned, it happens at // compiletime, so the compiler wouldn't have to warn indiscriminently, but @@ -2261,4 +2266,8 @@ general_span_iterator operator+(typename general_span_iterator::diff #pragma GCC diagnostic pop #endif // __GNUC__ > 6 +#if __clang__ || __GNUC__ +#pragma GCC diagnostic pop +#endif + #endif // GSL_MULTI_SPAN_H diff --git a/tests/bounds_tests.cpp b/tests/bounds_tests.cpp index 29c198a..da29e91 100644 --- a/tests/bounds_tests.cpp +++ b/tests/bounds_tests.cpp @@ -19,7 +19,11 @@ // so people aren't annoyed by them when running the tool. #pragma warning(disable : 26440 26426) // from catch #pragma warning(disable : 4996) // use of function or classes marked [[deprecated]] +#endif +#if __clang__ || __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wdeprecated-declarations" #endif #include // for AssertionHandler, StringRef, TEST_CASE @@ -115,3 +119,7 @@ TEST_CASE("bounds_convertible") #ifdef CONFIRM_COMPILATION_ERRORS copy(src_span_static, dst_span_static); #endif + +#if __clang__ || __GNUC__ +#pragma GCC diagnostic pop +#endif \ No newline at end of file diff --git a/tests/multi_span_tests.cpp b/tests/multi_span_tests.cpp index 97b2271..c4532bb 100644 --- a/tests/multi_span_tests.cpp +++ b/tests/multi_span_tests.cpp @@ -18,9 +18,13 @@ // blanket turn off warnings from CppCoreCheck from catch // so people aren't annoyed by them when running the tool. #pragma warning(disable : 26440 26426) // from catch -#pragma warning(disable : 4996) // multi_span is in the process of being deprecated. +//#pragma warning(disable : 4996) // multi_span is in the process of being deprecated. // Suppressing warnings until it is completely removed +#endif +#if __clang__ || __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wdeprecated-declarations" #endif #include // for AssertionHandler, StringRef, CHECK, CHECK... @@ -1785,3 +1789,7 @@ TEST_CASE("iterator") #ifdef CONFIRM_COMPILATION_ERRORS copy(src_span_static, dst_span_static); #endif + +#if __clang__ || __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/tests/strided_span_tests.cpp b/tests/strided_span_tests.cpp index 0d0896a..f201df4 100644 --- a/tests/strided_span_tests.cpp +++ b/tests/strided_span_tests.cpp @@ -20,7 +20,11 @@ #pragma warning(disable : 26440 26426) // from catch deprecated #pragma warning(disable : 4996) // strided_span is in the process of being deprecated. // Suppressing warnings until it is completely removed +#endif +#if __clang__ || __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wdeprecated-declarations" #endif #include // for AssertionHandler, StringRef, CHECK, CHECK... @@ -796,3 +800,7 @@ TEST_CASE("strided_span_conversion") i++; } } + +#if __clang__ || __GNUC__ +#pragma GCC diagnostic pop +#endif From 6ff4a5287df1108851bb5cdc0803da746e69f1ce Mon Sep 17 00:00:00 2001 From: Jordan Maples Date: Fri, 4 Oct 2019 14:13:54 -0700 Subject: [PATCH 11/14] accidentally commented out pragma --- tests/multi_span_tests.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/multi_span_tests.cpp b/tests/multi_span_tests.cpp index c4532bb..7c3e87c 100644 --- a/tests/multi_span_tests.cpp +++ b/tests/multi_span_tests.cpp @@ -18,7 +18,7 @@ // blanket turn off warnings from CppCoreCheck from catch // so people aren't annoyed by them when running the tool. #pragma warning(disable : 26440 26426) // from catch -//#pragma warning(disable : 4996) // multi_span is in the process of being deprecated. +#pragma warning(disable : 4996) // multi_span is in the process of being deprecated. // Suppressing warnings until it is completely removed #endif From 4b289d4cf08724984f91b33832f277ab1a018d1f Mon Sep 17 00:00:00 2001 From: Jordan Maples Date: Fri, 4 Oct 2019 14:15:24 -0700 Subject: [PATCH 12/14] lack of nl for bounds_test --- tests/bounds_tests.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/bounds_tests.cpp b/tests/bounds_tests.cpp index da29e91..d72e31a 100644 --- a/tests/bounds_tests.cpp +++ b/tests/bounds_tests.cpp @@ -122,4 +122,4 @@ copy(src_span_static, dst_span_static); #if __clang__ || __GNUC__ #pragma GCC diagnostic pop -#endif \ No newline at end of file +#endif From 275e0176c0b127866a33b25f9d60d77ee534b95f Mon Sep 17 00:00:00 2001 From: Sergei Izmailov Date: Sun, 6 Oct 2019 19:20:15 +0300 Subject: [PATCH 13/14] Fix typos in gsl/pointers --- include/gsl/pointers | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/include/gsl/pointers b/include/gsl/pointers index 0f2987a..7373826 100644 --- a/include/gsl/pointers +++ b/include/gsl/pointers @@ -197,7 +197,7 @@ namespace gsl // // Restricts a pointer or smart pointer to only hold non-null values, // -// - provides a strict (i.e. explicit contructor from T) wrapper of not_null +// - provides a strict (i.e. explicit constructor from T) wrapper of not_null // - to be used for new code that wishes the design to be cleaner and make not_null // checks intentional, or in old code that would like to make the transition. // @@ -205,9 +205,9 @@ namespace gsl // by strict_not_null and fix compilation errors // // Expect to -// - remove all unneded conversions from raw pointer to not_null and back -// - make API clear by specifyning not_null in parameters where needed -// - remove unnesessary asserts +// - remove all unneeded conversions from raw pointer to not_null and back +// - make API clear by specifying not_null in parameters where needed +// - remove unnecessary asserts // template class strict_not_null: public not_null From 0a78d8ea3c7dbb29a39f6cb2ae98710058f5b3a2 Mon Sep 17 00:00:00 2001 From: Matthias Moulin Date: Mon, 7 Oct 2019 21:49:50 +0200 Subject: [PATCH 14/14] Added std::exchange (C++14) to make the intent more explicit --- include/gsl/gsl_util | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/include/gsl/gsl_util b/include/gsl/gsl_util index 0fce689..e4b2daa 100644 --- a/include/gsl/gsl_util +++ b/include/gsl/gsl_util @@ -24,7 +24,7 @@ #include // for exception #include // for initializer_list #include // for is_signed, integral_constant -#include // for forward +#include // for exchange, forward #if defined(_MSC_VER) && !defined(__clang__) @@ -59,10 +59,7 @@ class final_action public: explicit final_action(F f) noexcept : f_(std::move(f)) {} - final_action(final_action&& other) noexcept : f_(std::move(other.f_)), invoke_(other.invoke_) - { - other.invoke_ = false; - } + final_action(final_action&& other) noexcept : f_(std::move(other.f_)), invoke_(std::exchange(other.invoke_, false)) {} final_action(const final_action&) = delete; final_action& operator=(const final_action&) = delete;