diff --git a/include/gsl/gsl_byte b/include/gsl/gsl_byte index 6e34a55..5da9a86 100644 --- a/include/gsl/gsl_byte +++ b/include/gsl/gsl_byte @@ -74,63 +74,63 @@ enum class byte : unsigned char }; template ::value>> -inline constexpr byte& operator<<=(byte& b, IntegerType shift) noexcept +constexpr byte& operator<<=(byte& b, IntegerType shift) noexcept { return b = byte(static_cast(b) << shift); } template ::value>> -inline constexpr byte operator<<(byte b, IntegerType shift) noexcept +constexpr byte operator<<(byte b, IntegerType shift) noexcept { return byte(static_cast(b) << shift); } template ::value>> -inline constexpr byte& operator>>=(byte& b, IntegerType shift) noexcept +constexpr byte& operator>>=(byte& b, IntegerType shift) noexcept { return b = byte(static_cast(b) >> shift); } template ::value>> -inline constexpr byte operator>>(byte b, IntegerType shift) noexcept +constexpr byte operator>>(byte b, IntegerType shift) noexcept { return byte(static_cast(b) >> shift); } -inline constexpr byte& operator|=(byte& l, byte r) noexcept +constexpr byte& operator|=(byte& l, byte r) noexcept { return l = byte(static_cast(l) | static_cast(r)); } -inline constexpr byte operator|(byte l, byte r) noexcept +constexpr byte operator|(byte l, byte r) noexcept { return byte(static_cast(l) | static_cast(r)); } -inline constexpr byte& operator&=(byte& l, byte r) noexcept +constexpr byte& operator&=(byte& l, byte r) noexcept { return l = byte(static_cast(l) & static_cast(r)); } -inline constexpr byte operator&(byte l, byte r) noexcept +constexpr byte operator&(byte l, byte r) noexcept { return byte(static_cast(l) & static_cast(r)); } -inline constexpr byte& operator^=(byte& l, byte r) noexcept +constexpr byte& operator^=(byte& l, byte r) noexcept { return l = byte(static_cast(l) ^ static_cast(r)); } -inline constexpr byte operator^(byte l, byte r) noexcept +constexpr byte operator^(byte l, byte r) noexcept { return byte(static_cast(l) ^ static_cast(r)); } -inline constexpr byte operator~(byte b) noexcept { return byte(~static_cast(b)); } +constexpr byte operator~(byte b) noexcept { return byte(~static_cast(b)); } template ::value>> -inline constexpr IntegerType to_integer(byte b) noexcept +constexpr IntegerType to_integer(byte b) noexcept { return static_cast(b); } @@ -138,7 +138,7 @@ inline constexpr IntegerType to_integer(byte b) noexcept #endif // GSL_USE_STD_BYTE template -inline constexpr byte to_byte_impl(T t) noexcept +constexpr byte to_byte_impl(T t) noexcept { static_assert( E, "gsl::to_byte(t) must be provided an unsigned char, otherwise data loss may occur. " @@ -146,19 +146,19 @@ inline constexpr byte to_byte_impl(T t) noexcept return static_cast(t); } template <> -inline constexpr byte to_byte_impl(unsigned char t) noexcept +constexpr byte to_byte_impl(unsigned char t) noexcept { return byte(t); } template -inline constexpr byte to_byte(T t) noexcept +constexpr byte to_byte(T t) noexcept { return to_byte_impl::value, T>(t); } template -inline constexpr byte to_byte() noexcept +constexpr byte to_byte() noexcept { static_assert(I >= 0 && I <= 255, "gsl::byte only has 8 bits of storage, values must be in range 0-255"); diff --git a/include/gsl/gsl_util b/include/gsl/gsl_util index eee63e7..b048a43 100644 --- a/include/gsl/gsl_util +++ b/include/gsl/gsl_util @@ -70,20 +70,21 @@ private: // finally() - convenience function to generate a final_action template -inline final_action finally(const F& f) noexcept + +final_action finally(const F& f) noexcept { return final_action(f); } template -inline final_action finally(F&& f) noexcept +final_action finally(F&& f) noexcept { return final_action(std::forward(f)); } // narrow_cast(): a searchable way to do narrowing casts of values template -inline constexpr T narrow_cast(U&& u) noexcept +constexpr T narrow_cast(U&& u) noexcept { return static_cast(std::forward(u)); } @@ -103,7 +104,7 @@ namespace details // narrow() : a checked version of narrow_cast() that throws if the cast changed the value template -inline T narrow(U u) +T narrow(U u) { T t = narrow_cast(u); if (static_cast(t) != u) throw narrowing_error(); @@ -116,14 +117,14 @@ inline T narrow(U u) // at() - Bounds-checked way of accessing builtin arrays, std::array, std::vector // template -inline constexpr T& at(T (&arr)[N], const std::ptrdiff_t index) +constexpr T& at(T (&arr)[N], const std::ptrdiff_t index) { Expects(index >= 0 && index < narrow_cast(N)); return arr[static_cast(index)]; } template -inline constexpr auto at(Cont& cont, const std::ptrdiff_t index) -> decltype(cont[cont.size()]) +constexpr auto at(Cont& cont, const std::ptrdiff_t index) -> decltype(cont[cont.size()]) { Expects(index >= 0 && index < narrow_cast(cont.size())); using size_type = decltype(cont.size()); @@ -131,7 +132,7 @@ inline constexpr auto at(Cont& cont, const std::ptrdiff_t index) -> decltype(con } template -inline constexpr T at(const std::initializer_list cont, const std::ptrdiff_t index) +constexpr T at(const std::initializer_list cont, const std::ptrdiff_t index) { Expects(index >= 0 && index < narrow_cast(cont.size())); return *(cont.begin() + index); diff --git a/include/gsl/multi_span b/include/gsl/multi_span index 9dce739..cf82144 100644 --- a/include/gsl/multi_span +++ b/include/gsl/multi_span @@ -498,7 +498,7 @@ namespace details template 1), typename Ret = std::enable_if_t>> - inline constexpr Ret shift_left(const index& other) GSL_NOEXCEPT + constexpr Ret shift_left(const index& other) GSL_NOEXCEPT { Ret ret{}; for (std::size_t i = 0; i < Rank - 1; ++i) { @@ -996,7 +996,7 @@ bounds_iterator operator+(typename bounds_iterator::differ namespace details { template - inline constexpr std::enable_if_t< + constexpr std::enable_if_t< std::is_same::value, typename Bounds::index_type> make_stride(const Bounds& bnd) GSL_NOEXCEPT @@ -1006,7 +1006,7 @@ namespace details // Make a stride vector from bounds, assuming contiguous memory. template - inline constexpr std::enable_if_t< + constexpr std::enable_if_t< std::is_same::value, typename Bounds::index_type> make_stride(const Bounds& bnd) GSL_NOEXCEPT @@ -1056,13 +1056,13 @@ struct dim_t }; template = 0)>> -inline constexpr dim_t dim() GSL_NOEXCEPT +constexpr dim_t dim() GSL_NOEXCEPT { return dim_t(); } template > -inline constexpr dim_t dim(std::ptrdiff_t n) GSL_NOEXCEPT +constexpr dim_t dim(std::ptrdiff_t n) GSL_NOEXCEPT { return dim_t<>(n); } @@ -1599,7 +1599,7 @@ public: // DimCount and Enabled here are workarounds for a bug in MSVC 2015 template 0), typename = std::enable_if_t> -inline 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, @@ -1637,7 +1637,7 @@ multi_span as_writeable_bytes(multi_span s) GSL_NOEXCEPT // on all implementations. It should be considered an experimental extension // to the standard GSL interface. template -inline constexpr auto +constexpr auto as_multi_span(multi_span s) GSL_NOEXCEPT -> multi_span< const U, static_cast( multi_span::bounds_type::static_size != dynamic_range @@ -1664,7 +1664,7 @@ as_multi_span(multi_span s) GSL_NOEXCEPT -> multi_spa // on all implementations. It should be considered an experimental extension // to the standard GSL interface. template -inline constexpr auto as_multi_span(multi_span s) GSL_NOEXCEPT +constexpr auto as_multi_span(multi_span s) GSL_NOEXCEPT -> multi_span( multi_span::bounds_type::static_size != dynamic_range ? static_cast( @@ -1685,7 +1685,7 @@ inline constexpr auto as_multi_span(multi_span s) GSL_NOEXC } template -inline 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), @@ -1694,41 +1694,41 @@ inline constexpr auto as_multi_span(T* const& ptr, dim_t... args) } template -inline 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 -inline constexpr auto as_multi_span(T (&arr)[N]) -> typename details::SpanArrayTraits::type +constexpr auto as_multi_span(T (&arr)[N]) -> typename details::SpanArrayTraits::type { return {arr}; } template -inline constexpr multi_span as_multi_span(const std::array& arr) +constexpr multi_span as_multi_span(const std::array& arr) { return {arr}; } template -inline constexpr multi_span as_multi_span(const std::array&&) = delete; +constexpr multi_span as_multi_span(const std::array&&) = delete; template -inline constexpr multi_span as_multi_span(std::array& arr) +constexpr multi_span as_multi_span(std::array& arr) { return {arr}; } template -inline constexpr multi_span as_multi_span(T* begin, T* end) +constexpr multi_span as_multi_span(T* begin, T* end) { return {begin, end}; } template -inline 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>> { @@ -1737,13 +1737,13 @@ inline constexpr auto as_multi_span(Cont& arr) -> std::enable_if_t< } template -inline 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 -inline 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); diff --git a/include/gsl/span b/include/gsl/span index 04cf1af..6f87633 100644 --- a/include/gsl/span +++ b/include/gsl/span @@ -253,7 +253,7 @@ namespace details }; template - inline constexpr span_iterator + constexpr span_iterator operator+(typename span_iterator::difference_type n, span_iterator rhs) GSL_NOEXCEPT { @@ -261,7 +261,7 @@ namespace details } template - inline constexpr span_iterator + constexpr span_iterator operator-(typename span_iterator::difference_type n, span_iterator rhs) GSL_NOEXCEPT { @@ -535,43 +535,43 @@ private: // [span.comparison], span comparison operators template -inline constexpr bool operator==(span l, - span r) +constexpr bool operator==(span l, + span r) { return std::equal(l.begin(), l.end(), r.begin(), r.end()); } template -inline constexpr bool operator!=(span l, - span r) +constexpr bool operator!=(span l, + span r) { return !(l == r); } template -inline constexpr bool operator<(span l, - span r) +constexpr bool operator<(span l, + span r) { return std::lexicographical_compare(l.begin(), l.end(), r.begin(), r.end()); } template -inline constexpr bool operator<=(span l, - span r) +constexpr bool operator<=(span l, + span r) { return !(l > r); } template -inline constexpr bool operator>(span l, - span r) +constexpr bool operator>(span l, + span r) { return r < l; } template -inline constexpr bool operator>=(span l, - span r) +constexpr bool operator>=(span l, + span r) { return !(l < r); } @@ -662,7 +662,7 @@ span make_span(Ptr& cont) // Specialization of gsl::at for span template -inline constexpr ElementType& at(span s, std::ptrdiff_t index) +constexpr ElementType& at(span s, std::ptrdiff_t index) { // No bounds checking here because it is done in span::operator[] called below return s[index]; diff --git a/include/gsl/string_span b/include/gsl/string_span index cd9ddf9..e4b186f 100644 --- a/include/gsl/string_span +++ b/include/gsl/string_span @@ -130,7 +130,7 @@ span ensure_sentinel(T* seq, std::ptrdiff_t max = PTRDIFF_MAX // the limit of size_type. // template -inline span ensure_z(CharT* const& sz, std::ptrdiff_t max = PTRDIFF_MAX) +span ensure_z(CharT* const& sz, std::ptrdiff_t max = PTRDIFF_MAX) { return ensure_sentinel(sz, max); }