possible solution to #567

This commit is contained in:
menete 2017-11-06 19:30:44 +01:00
parent d10ebc6555
commit 8cb8dfeed6
3 changed files with 37 additions and 8 deletions

View File

@ -25,5 +25,6 @@
#include <gsl/span> // span #include <gsl/span> // span
#include <gsl/string_span> // zstring, string_span, zstring_builder... #include <gsl/string_span> // zstring, string_span, zstring_builder...
#include <gsl/pointers> // owner, not_null #include <gsl/pointers> // owner, not_null
#include <gsl/pointers_ios>// ostream operator for not_null
#endif // GSL_GSL_H #endif // GSL_GSL_H

View File

@ -21,7 +21,6 @@
#include <gsl/gsl_assert> #include <gsl/gsl_assert>
#include <iostream>
#include <memory> #include <memory>
#include <type_traits> #include <type_traits>
@ -112,13 +111,6 @@ private:
T ptr_; T ptr_;
}; };
template <class T>
std::ostream& operator<<(std::ostream& os, const not_null<T>& val)
{
os << val.get();
return os;
}
template <class T, class U> template <class T, class U>
auto operator==(const not_null<T>& lhs, const not_null<U>& rhs) -> decltype(lhs.get() == rhs.get()) auto operator==(const not_null<T>& lhs, const not_null<U>& rhs) -> decltype(lhs.get() == rhs.get())
{ {

36
include/gsl/pointers_ios Normal file
View File

@ -0,0 +1,36 @@
///////////////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2015 Microsoft Corporation. All rights reserved.
//
// This code is licensed under the MIT License (MIT).
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
//
///////////////////////////////////////////////////////////////////////////////
#pragma once
#ifndef GSL_POINTERS_IOS_H
#define GSL_POINTERS_IOS_H
#include <iostream>
#include <gsl/pointers>
namespace gsl
{
template <class T>
std::ostream& operator<<(std::ostream& os, const not_null<T>& val)
{
os << val.get();
return os;
}
}
#endif