Reworked span to match GSL design.

This commit is contained in:
Neil MacIntosh
2015-11-24 12:49:03 -08:00
parent 38eaf9fc95
commit 0cf947db77
7 changed files with 3302 additions and 2583 deletions

View File

@ -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)

View File

@ -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; }
//

File diff suppressed because it is too large Load Diff