diff options
author | mtnpke <72438900+mtnpke@users.noreply.github.com> | 2020-10-29 01:37:02 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-10-29 01:37:02 +0300 |
commit | 736b62a838335dabc7cea01f808575a47195bd47 (patch) | |
tree | f2bb8c3738bc88b9ae3a03e2526d9d362664afc1 | |
parent | 6f4529395c5b7c2d661812257cd6780c67e54afa (diff) |
Allow usage on platforms not providing iostreams (#935)
Closes #933.
-rw-r--r-- | include/gsl/pointers | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/include/gsl/pointers b/include/gsl/pointers index 874583d..f7c3885 100644 --- a/include/gsl/pointers +++ b/include/gsl/pointers @@ -20,11 +20,15 @@ #include <gsl/gsl_assert> // for Ensures, Expects #include <algorithm> // for forward -#include <iosfwd> // for ptrdiff_t, nullptr_t, ostream, size_t +#include <cstddef> // for ptrdiff_t, nullptr_t, size_t #include <memory> // for shared_ptr, unique_ptr #include <system_error> // for hash #include <type_traits> // for enable_if_t, is_convertible, is_assignable +#if !defined(GSL_NO_IOSTREAMS) +#include <iosfwd> // for ostream +#endif // !defined(GSL_NO_IOSTREAMS) + namespace gsl { @@ -116,12 +120,14 @@ auto make_not_null(T&& t) noexcept { return not_null<std::remove_cv_t<std::remove_reference_t<T>>>{std::forward<T>(t)}; } +#if !defined(GSL_NO_IOSTREAMS) template <class T> std::ostream& operator<<(std::ostream& os, const not_null<T>& val) { os << val.get(); return os; } +#endif // !defined(GSL_NO_IOSTREAMS) template <class T, class U> auto operator==(const not_null<T>& lhs, const not_null<U>& rhs) noexcept(noexcept(lhs.get() == rhs.get())) -> decltype(lhs.get() == rhs.get()) |