1 // Copyright 2015 by Martin Moene
2 //
3 // gsl-lite is based on GSL: Guideline Support Library.
4 // For more information see https://github.com/martinmoene/gsl-lite
5 //
6 // This code is licensed under the MIT License (MIT).
7 //
8 
9 #pragma once
10 
11 #ifndef GSL_TEST_GSL_LITE_H_INCLUDED
12 #define GSL_TEST_GSL_LITE_H_INCLUDED
13 
14 #if defined(_MSC_VER) && _MSC_VER < 1300
15 # include "gsl-lite-vc6.h"
16 #else
17 # include "gsl-lite.h"
18 #endif
19 
20 #include "lest_cpp03.hpp"
21 
22 using namespace gsl;
23 
24 #define CASE( name ) lest_CASE( specification(), name )
25 
26 extern lest::tests & specification();
27 
28 #if ! gsl_BETWEEN( gsl_COMPILER_MSVC_VERSION, 6, 7 )
29 namespace std {
30 #else
31 namespace lest {
32 #endif
33 
34 #if gsl_HAVE_ARRAY
35 template< typename T, std::size_t N >
operator <<( std::ostream & os, std::array<T,N> const & a )36 inline std::ostream & operator<<( std::ostream & os, std::array<T,N> const & a )
37 {
38     return os << std::hex << "[std::array[" << N << "]";
39 }
40 #endif
41 
operator <<( std::ostream & os, std::wstring const & text )42 inline std::ostream & operator<<( std::ostream & os, std::wstring const & text )
43 {
44 #if ! gsl_BETWEEN( gsl_COMPILER_MSVC_VERSION, 6, 7 )
45     return os << std::string( text.begin(), text.end() );
46 #else
47     std::copy( text.begin(), text.end(), std::ostream_iterator<char>(os) ); return os;
48 #endif
49 }
50 
51 #if ! gsl_BETWEEN( gsl_COMPILER_MSVC_VERSION, 6, 7 )
52 } // namespace std
53 #else
54 } // namespace lest
55 #endif
56 
57 namespace gsl {
58 
nullptr_void()59 inline const void * nullptr_void() { return 0; }
60 
61 // use oparator<< instead of to_string() overload;
62 // see  http://stackoverflow.com/a/10651752/437272
63 
operator <<( std::ostream & os, byte b )64 inline std::ostream & operator<<( std::ostream & os, byte b )
65 {
66     return os << std::hex << "0x" << to_integer<int>(b);
67 }
68 
69 template< typename T >
operator <<( std::ostream & os, span<T> s )70 inline std::ostream & operator<<( std::ostream & os, span<T> s )
71 {
72     return os << "[", std::copy( s.begin(), s.end(), std::ostream_iterator<T>(os, ",") ), os << "]";
73 }
74 
75 } // namespace gsl
76 
77 #endif // GSL_TEST_GSL_LITE_H_INCLUDED
78 
79 // end of file
80