mirror of
https://github.com/microsoft/GSL.git
synced 2024-11-03 17:56:43 -05:00
Merge pull request #937 from beinhaerter/cast_warning
eliminate warning, use narrow_cast instead of static_cast
This commit is contained in:
commit
6432f920ea
@ -19,6 +19,7 @@
|
||||
|
||||
#include <gsl/gsl_assert> // for Expects
|
||||
#include <gsl/gsl_byte> // for byte
|
||||
#include <gsl/gsl_util> // for narrow_cast
|
||||
|
||||
#include <array> // for array
|
||||
#include <cstddef> // for ptrdiff_t, size_t, nullptr_t
|
||||
@ -433,14 +434,14 @@ public:
|
||||
|
||||
template <std::size_t MyExtent = Extent, std::enable_if_t<MyExtent != dynamic_extent, int> = 0>
|
||||
constexpr explicit span(pointer firstElem, pointer lastElem) noexcept
|
||||
: storage_(firstElem, static_cast<std::size_t>(lastElem - firstElem))
|
||||
: storage_(firstElem, narrow_cast<std::size_t>(lastElem - firstElem))
|
||||
{
|
||||
Expects(lastElem - firstElem == static_cast<difference_type>(Extent));
|
||||
}
|
||||
|
||||
template <std::size_t MyExtent = Extent, std::enable_if_t<MyExtent == dynamic_extent, int> = 0>
|
||||
constexpr span(pointer firstElem, pointer lastElem) noexcept
|
||||
: storage_(firstElem, static_cast<std::size_t>(lastElem - firstElem))
|
||||
: storage_(firstElem, narrow_cast<std::size_t>(lastElem - firstElem))
|
||||
{}
|
||||
|
||||
template <std::size_t N,
|
||||
|
Loading…
Reference in New Issue
Block a user