mirror of
https://github.com/microsoft/GSL.git
synced 2025-05-13 01:15:18 -04:00
Reworked span to match GSL design.
This commit is contained in:
@ -55,9 +55,9 @@ struct fail_fast : public std::runtime_error
|
||||
}
|
||||
|
||||
#define Expects(cond) if (!(cond)) \
|
||||
throw gsl::fail_fast("GSL: Precondition failure at " __FILE__ GSL_STRINGIFY(__LINE__));
|
||||
throw gsl::fail_fast("GSL: Precondition failure at " __FILE__ ": " GSL_STRINGIFY(__LINE__));
|
||||
#define Ensures(cond) if (!(cond)) \
|
||||
throw gsl::fail_fast("GSL: Postcondition failure at " __FILE__ GSL_STRINGIFY(__LINE__));
|
||||
throw gsl::fail_fast("GSL: Postcondition failure at " __FILE__ ": " GSL_STRINGIFY(__LINE__));
|
||||
|
||||
|
||||
#elif defined(GSL_TERMINATE_ON_CONTRACT_VIOLATION)
|
||||
|
@ -76,23 +76,23 @@ private:
|
||||
|
||||
// finally() - convenience function to generate a final_act
|
||||
template <class F>
|
||||
final_act<F> finally(const F &f)
|
||||
inline final_act<F> finally(const F &f)
|
||||
noexcept { return final_act<F>(f); }
|
||||
|
||||
template <class F>
|
||||
final_act<F> finally(F &&f) noexcept
|
||||
inline final_act<F> finally(F &&f) noexcept
|
||||
{ return final_act<F>(std::forward<F>(f)); }
|
||||
|
||||
// narrow_cast(): a searchable way to do narrowing casts of values
|
||||
template<class T, class U>
|
||||
constexpr T narrow_cast(U u) noexcept
|
||||
inline constexpr T narrow_cast(U u) noexcept
|
||||
{ return static_cast<T>(u); }
|
||||
|
||||
struct narrowing_error : public std::exception {};
|
||||
|
||||
// narrow() : a checked version of narrow_cast() that throws if the cast changed the value
|
||||
template<class T, class U>
|
||||
T narrow(U u)
|
||||
inline T narrow(U u)
|
||||
{ T t = narrow_cast<T>(u); if (static_cast<U>(t) != u) throw narrowing_error(); return t; }
|
||||
|
||||
//
|
||||
|
1813
include/span.h
1813
include/span.h
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user