mirror of
https://github.com/microsoft/GSL.git
synced 2024-11-03 17:56:43 -05:00
Minor refactoring to use <type_traits> and use available value in static_assert.
This commit is contained in:
parent
8ae77b1fd5
commit
33e61f0115
@ -81,9 +81,9 @@ namespace details
|
|||||||
template <typename OtherConcreteType, typename OtherValueType, unsigned int OtherRank>
|
template <typename OtherConcreteType, typename OtherValueType, unsigned int OtherRank>
|
||||||
friend class coordinate_facade;
|
friend class coordinate_facade;
|
||||||
public:
|
public:
|
||||||
using reference = ValueType&;
|
using reference = typename std::add_lvalue_reference<ValueType>::type;
|
||||||
using const_reference = const ValueType&;
|
using const_reference = typename std::add_lvalue_reference<typename std::add_const<ValueType>::type>::type;
|
||||||
using value_type = ValueType;
|
using value_type = typename std::remove_reference<typename std::remove_cv<ValueType>::type>::type;
|
||||||
static const unsigned int rank = Rank;
|
static const unsigned int rank = Rank;
|
||||||
_CONSTEXPR coordinate_facade() _NOEXCEPT
|
_CONSTEXPR coordinate_facade() _NOEXCEPT
|
||||||
{
|
{
|
||||||
@ -500,8 +500,8 @@ namespace details
|
|||||||
template <typename SizeType, SizeType Fact1, SizeType Fact2, SizeType ConstBound>
|
template <typename SizeType, SizeType Fact1, SizeType Fact2, SizeType ConstBound>
|
||||||
struct StaticSizeHelperImpl
|
struct StaticSizeHelperImpl
|
||||||
{
|
{
|
||||||
static_assert(static_cast<size_t>(Fact1) * static_cast<size_t>(Fact2) <= SizeTypeTraits<SizeType>::max_value, "Value out of the range of SizeType");
|
|
||||||
static const SizeType value = Fact1 * Fact2;
|
static const SizeType value = Fact1 * Fact2;
|
||||||
|
static_assert(static_cast<size_t>(value) <= SizeTypeTraits<SizeType>::max_value, "Value out of the range of SizeType");
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename SizeType, SizeType Fact1, SizeType ConstBound>
|
template <typename SizeType, SizeType Fact1, SizeType ConstBound>
|
||||||
|
Loading…
Reference in New Issue
Block a user