From 736b62a838335dabc7cea01f808575a47195bd47 Mon Sep 17 00:00:00 2001 From: mtnpke <72438900+mtnpke@users.noreply.github.com> Date: Wed, 28 Oct 2020 23:37:02 +0100 Subject: [PATCH] Allow usage on platforms not providing iostreams (#935) Closes #933. --- include/gsl/pointers | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) 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 // for Ensures, Expects #include // for forward -#include // for ptrdiff_t, nullptr_t, ostream, size_t +#include // for ptrdiff_t, nullptr_t, size_t #include // for shared_ptr, unique_ptr #include // for hash #include // for enable_if_t, is_convertible, is_assignable +#if !defined(GSL_NO_IOSTREAMS) +#include // for ostream +#endif // !defined(GSL_NO_IOSTREAMS) + namespace gsl { @@ -116,12 +120,14 @@ auto make_not_null(T&& t) noexcept { return not_null>>{std::forward(t)}; } +#if !defined(GSL_NO_IOSTREAMS) template std::ostream& operator<<(std::ostream& os, const not_null& val) { os << val.get(); return os; } +#endif // !defined(GSL_NO_IOSTREAMS) template auto operator==(const not_null& lhs, const not_null& rhs) noexcept(noexcept(lhs.get() == rhs.get())) -> decltype(lhs.get() == rhs.get())