mirror of
https://github.com/microsoft/GSL.git
synced 2024-11-03 17:56:43 -05:00
Merge branch 'master' into dev/neilmac/iterators
This commit is contained in:
commit
6b4ae834a3
@ -3,10 +3,10 @@ cmake_minimum_required(VERSION 2.8.7)
|
|||||||
project(GSL CXX)
|
project(GSL CXX)
|
||||||
|
|
||||||
set(GSL_HEADERS
|
set(GSL_HEADERS
|
||||||
"include/gsl.h"
|
"gsl/gsl"
|
||||||
"include/gsl_assert.h"
|
"gsl/gsl_assert"
|
||||||
"include/span.h"
|
"gsl/span"
|
||||||
"include/string_span.h"
|
"gsl/string_span"
|
||||||
)
|
)
|
||||||
|
|
||||||
include_directories(
|
include_directories(
|
||||||
|
24
README.md
24
README.md
@ -6,10 +6,10 @@ This repo contains Microsoft's implementation of GSL.
|
|||||||
|
|
||||||
The library includes types like `span<T>`, `string_span`, `owner<>` and others.
|
The library includes types like `span<T>`, `string_span`, `owner<>` and others.
|
||||||
|
|
||||||
The entire implementation is provided inline in the headers under the [include](./include) directory. The implementation generally assumes a platform that implements C++14 support. There are specific workarounds to support MSVC 2013 and 2015.
|
The entire implementation is provided inline in the headers under the [gsl](./gsl) directory. The implementation generally assumes a platform that implements C++14 support. There are specific workarounds to support MSVC 2013 and 2015.
|
||||||
|
|
||||||
While some types have been broken out into their own headers (e.g. [include/span.h](./include/span.h)),
|
While some types have been broken out into their own headers (e.g. [gsl/span](./gsl/span)),
|
||||||
it is simplest to just include [gsl.h](./include/gsl.h) and gain access to the entire library.
|
it is simplest to just include [gsl/gsl](./gsl/gsl) and gain access to the entire library.
|
||||||
|
|
||||||
> NOTE: We encourage contributions that improve or refine any of the types in this library as well as ports to
|
> NOTE: We encourage contributions that improve or refine any of the types in this library as well as ports to
|
||||||
other platforms. Please see [CONTRIBUTING.md](./CONTRIBUTING.md) for more information about contributing.
|
other platforms. Please see [CONTRIBUTING.md](./CONTRIBUTING.md) for more information about contributing.
|
||||||
@ -66,5 +66,19 @@ All tests should pass - indicating your platform is fully supported and you are
|
|||||||
## Using the libraries
|
## Using the libraries
|
||||||
As the types are entirely implemented inline in headers, there are no linking requirements.
|
As the types are entirely implemented inline in headers, there are no linking requirements.
|
||||||
|
|
||||||
Just place the contents of the [include](./include) directory within your source tree so it is available
|
You can copy the [gsl](./gsl) directory into your source tree so it is available
|
||||||
to your compiler, then include the appropriate headers in your program, and away you go!
|
to your compiler, then include the appropriate headers in your program.
|
||||||
|
|
||||||
|
Alternatively set your compiler's *include path* flag to point to the GSL development folder (`c:\GSL` in the example above) or installation folder (after running the install). Eg.
|
||||||
|
|
||||||
|
MSVC++
|
||||||
|
|
||||||
|
/I c:\GSL
|
||||||
|
|
||||||
|
GCC/clang
|
||||||
|
|
||||||
|
-I$HOME/dev/GSL
|
||||||
|
|
||||||
|
Include the library using:
|
||||||
|
|
||||||
|
#include <gsl/gsl>
|
||||||
|
@ -19,11 +19,11 @@
|
|||||||
#ifndef GSL_GSL_H
|
#ifndef GSL_GSL_H
|
||||||
#define GSL_GSL_H
|
#define GSL_GSL_H
|
||||||
|
|
||||||
#include "gsl_assert.h" // Ensures/Expects
|
#include "gsl_assert" // Ensures/Expects
|
||||||
#include "gsl_util.h" // finally()/narrow()/narrow_cast()...
|
#include "gsl_util" // finally()/narrow()/narrow_cast()...
|
||||||
#include "multi_span.h" // multi_span, strided_span...
|
#include "multi_span" // multi_span, strided_span...
|
||||||
#include "span.h" // span
|
#include "span" // span
|
||||||
#include "string_span.h" // zstring, string_span, zstring_builder...
|
#include "string_span" // zstring, string_span, zstring_builder...
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
@ -19,7 +19,7 @@
|
|||||||
#ifndef GSL_UTIL_H
|
#ifndef GSL_UTIL_H
|
||||||
#define GSL_UTIL_H
|
#define GSL_UTIL_H
|
||||||
|
|
||||||
#include "gsl_assert.h" // Ensures/Expects
|
#include "gsl_assert" // Ensures/Expects
|
||||||
#include <array>
|
#include <array>
|
||||||
#include <exception>
|
#include <exception>
|
||||||
#include <type_traits>
|
#include <type_traits>
|
@ -19,9 +19,9 @@
|
|||||||
#ifndef GSL_MULTI_SPAN_H
|
#ifndef GSL_MULTI_SPAN_H
|
||||||
#define GSL_MULTI_SPAN_H
|
#define GSL_MULTI_SPAN_H
|
||||||
|
|
||||||
#include "gsl_assert.h"
|
#include "gsl_assert"
|
||||||
#include "gsl_byte.h"
|
#include "gsl_byte"
|
||||||
#include "gsl_util.h"
|
#include "gsl_util"
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <array>
|
#include <array>
|
||||||
#include <cassert>
|
#include <cassert>
|
@ -20,9 +20,9 @@
|
|||||||
#ifndef GSL_SPAN_H
|
#ifndef GSL_SPAN_H
|
||||||
#define GSL_SPAN_H
|
#define GSL_SPAN_H
|
||||||
|
|
||||||
#include "gsl_assert.h"
|
#include "gsl_assert"
|
||||||
#include "gsl_byte.h"
|
#include "gsl_byte"
|
||||||
#include "gsl_util.h"
|
#include "gsl_util"
|
||||||
#include <array>
|
#include <array>
|
||||||
#include <iterator>
|
#include <iterator>
|
||||||
#include <limits>
|
#include <limits>
|
||||||
@ -681,10 +681,13 @@ as_writeable_bytes(span<ElementType, Extent> s) noexcept
|
|||||||
#undef noexcept
|
#undef noexcept
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
#pragma warning(pop)
|
|
||||||
#pragma pop_macro("noexcept")
|
#pragma pop_macro("noexcept")
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif // GSL_THROW_ON_CONTRACT_VIOLATION
|
#endif // GSL_THROW_ON_CONTRACT_VIOLATION
|
||||||
|
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
#pragma warning(pop)
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif // GSL_SPAN_H
|
#endif // GSL_SPAN_H
|
@ -19,9 +19,9 @@
|
|||||||
#ifndef GSL_STRING_SPAN_H
|
#ifndef GSL_STRING_SPAN_H
|
||||||
#define GSL_STRING_SPAN_H
|
#define GSL_STRING_SPAN_H
|
||||||
|
|
||||||
#include "gsl_assert.h"
|
#include "gsl_assert"
|
||||||
#include "gsl_util.h"
|
#include "gsl_util"
|
||||||
#include "span.h"
|
#include "span"
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <string>
|
#include <string>
|
@ -9,7 +9,7 @@ endif()
|
|||||||
add_subdirectory(unittest-cpp)
|
add_subdirectory(unittest-cpp)
|
||||||
|
|
||||||
include_directories(
|
include_directories(
|
||||||
../include
|
..
|
||||||
./unittest-cpp
|
./unittest-cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -33,7 +33,7 @@ else()
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
function(add_gsl_test name)
|
function(add_gsl_test name)
|
||||||
add_executable(${name} ${name}.cpp ../include/gsl.h ../include/gsl_assert.h ../include/gsl_util.h ../include/multi_span.h ../include/span.h ../include/string_span.h)
|
add_executable(${name} ${name}.cpp ../gsl/gsl ../gsl/gsl_assert ../gsl/gsl_util ../gsl/multi_span ../gsl/span ../gsl/string_span)
|
||||||
target_link_libraries(${name} UnitTest++)
|
target_link_libraries(${name} UnitTest++)
|
||||||
install(TARGETS ${name}
|
install(TARGETS ${name}
|
||||||
RUNTIME DESTINATION bin
|
RUNTIME DESTINATION bin
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
#include <UnitTest++/UnitTest++.h>
|
#include <UnitTest++/UnitTest++.h>
|
||||||
#include <gsl.h>
|
#include <gsl/gsl>
|
||||||
|
|
||||||
using namespace gsl;
|
using namespace gsl;
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
#include <UnitTest++/UnitTest++.h>
|
#include <UnitTest++/UnitTest++.h>
|
||||||
#include <gsl.h>
|
#include <gsl/gsl>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <initializer_list>
|
#include <initializer_list>
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
#include <UnitTest++/UnitTest++.h>
|
#include <UnitTest++/UnitTest++.h>
|
||||||
#include <multi_span.h>
|
#include <gsl/multi_span>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
#include <UnitTest++/UnitTest++.h>
|
#include <UnitTest++/UnitTest++.h>
|
||||||
#include <gsl_byte.h>
|
#include <gsl/gsl_byte>
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <list>
|
#include <list>
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
#include <UnitTest++/UnitTest++.h>
|
#include <UnitTest++/UnitTest++.h>
|
||||||
#include <multi_span.h>
|
#include <gsl/multi_span>
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <list>
|
#include <list>
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
#include <UnitTest++/UnitTest++.h>
|
#include <UnitTest++/UnitTest++.h>
|
||||||
#include <gsl.h>
|
#include <gsl/gsl>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
using namespace gsl;
|
using namespace gsl;
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
#include <UnitTest++/UnitTest++.h>
|
#include <UnitTest++/UnitTest++.h>
|
||||||
#include <gsl.h>
|
#include <gsl/gsl>
|
||||||
#include <functional>
|
#include <functional>
|
||||||
|
|
||||||
using namespace gsl;
|
using namespace gsl;
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
#include <UnitTest++/UnitTest++.h>
|
#include <UnitTest++/UnitTest++.h>
|
||||||
#include <span.h>
|
#include <gsl/span>
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <list>
|
#include <list>
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
#include <UnitTest++/UnitTest++.h>
|
#include <UnitTest++/UnitTest++.h>
|
||||||
#include <multi_span.h>
|
#include <gsl/multi_span>
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
@ -16,8 +16,9 @@
|
|||||||
|
|
||||||
#include <UnitTest++/UnitTest++.h>
|
#include <UnitTest++/UnitTest++.h>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <string_span.h>
|
#include <gsl/string_span>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
#include <map>
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace gsl;
|
using namespace gsl;
|
||||||
@ -942,7 +943,13 @@ SUITE(string_span_tests)
|
|||||||
CHECK(*(str + 3) == L'\0');
|
CHECK(*(str + 3) == L'\0');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(Issue305)
|
||||||
|
{
|
||||||
|
std::map<gsl::cstring_span<>, int> foo = { { "foo", 0 },{ "bar", 1 } };
|
||||||
|
CHECK(foo["foo"] == 0);
|
||||||
|
CHECK(foo["bar"] == 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
#include <UnitTest++/UnitTest++.h>
|
#include <UnitTest++/UnitTest++.h>
|
||||||
#include <gsl.h>
|
#include <gsl/gsl>
|
||||||
#include <functional>
|
#include <functional>
|
||||||
|
|
||||||
using namespace gsl;
|
using namespace gsl;
|
||||||
|
Loading…
Reference in New Issue
Block a user