From ebce4920d66816f8c9addb288cfe67bef41f07a2 Mon Sep 17 00:00:00 2001 From: Neil MacIntosh Date: Tue, 2 Aug 2016 16:22:18 -0700 Subject: [PATCH 1/4] Fixed #308 - a mismatched pragma. --- include/span.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/include/span.h b/include/span.h index a612983..b7a3d77 100644 --- a/include/span.h +++ b/include/span.h @@ -2221,10 +2221,13 @@ general_span_iterator operator+(typename general_span_iterator::diff #undef noexcept #ifdef _MSC_VER -#pragma warning(pop) #pragma pop_macro("noexcept") #endif #endif // GSL_THROW_ON_CONTRACT_VIOLATION +#ifdef _MSC_VER +#pragma warning(pop) +#endif + #endif // GSL_SPAN_H From f6cc5798a17daccf806bbc402a67c92d1a205091 Mon Sep 17 00:00:00 2001 From: galik Date: Tue, 9 Aug 2016 15:04:58 +0100 Subject: [PATCH 2/4] Renamed include/ folder to gsl/ to make including the library consistent whether using it from the development folder, from the installation folder or from being copied into a project. #include Updated headers/tests/instructions/cmake build accordingly This PR should address https://github.com/Microsoft/GSL/issues/277 (less the renaming of gsl itself) --- CMakeLists.txt | 8 ++++---- README.md | 25 ++++++++++++++++++++----- {include => gsl}/gsl.h | 0 {include => gsl}/gsl_assert.h | 0 {include => gsl}/gsl_byte.h | 0 {include => gsl}/gsl_util.h | 0 {include => gsl}/multi_span.h | 0 {include => gsl}/span.h | 0 {include => gsl}/string_span.h | 0 tests/CMakeLists.txt | 4 ++-- tests/assertion_tests.cpp | 2 +- tests/at_tests.cpp | 2 +- tests/bounds_tests.cpp | 2 +- tests/byte_tests.cpp | 2 +- tests/multi_span_tests.cpp | 2 +- tests/notnull_tests.cpp | 2 +- tests/owner_tests.cpp | 2 +- tests/span_tests.cpp | 2 +- tests/strided_span_tests.cpp | 2 +- tests/string_span_tests.cpp | 2 +- tests/utils_tests.cpp | 2 +- 21 files changed, 37 insertions(+), 22 deletions(-) rename {include => gsl}/gsl.h (100%) rename {include => gsl}/gsl_assert.h (100%) rename {include => gsl}/gsl_byte.h (100%) rename {include => gsl}/gsl_util.h (100%) rename {include => gsl}/multi_span.h (100%) rename {include => gsl}/span.h (100%) rename {include => gsl}/string_span.h (100%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7397fe2..ba85857 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,10 +3,10 @@ cmake_minimum_required(VERSION 2.8.7) project(GSL CXX) set(GSL_HEADERS - "include/gsl.h" - "include/gsl_assert.h" - "include/span.h" - "include/string_span.h" + "gsl/gsl.h" + "gsl/gsl_assert.h" + "gsl/span.h" + "gsl/string_span.h" ) include_directories( diff --git a/README.md b/README.md index 3c440c2..f54b0c5 100644 --- a/README.md +++ b/README.md @@ -6,10 +6,10 @@ This repo contains Microsoft's implementation of GSL. The library includes types like `span`, `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)), -it is simplest to just include [gsl.h](./include/gsl.h) and gain access to the entire library. +While some types have been broken out into their own headers (e.g. [gsl/span.h](./gsl/span.h)), +it is simplest to just include [gsl/gsl.h](./gsl/gsl.h) 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 other platforms. Please see [CONTRIBUTING.md](./CONTRIBUTING.md) for more information about contributing. @@ -66,5 +66,20 @@ All tests should pass - indicating your platform is fully supported and you are ## Using the libraries 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 -to your compiler, then include the appropriate headers in your program, and away you go! +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. + +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 diff --git a/include/gsl.h b/gsl/gsl.h similarity index 100% rename from include/gsl.h rename to gsl/gsl.h diff --git a/include/gsl_assert.h b/gsl/gsl_assert.h similarity index 100% rename from include/gsl_assert.h rename to gsl/gsl_assert.h diff --git a/include/gsl_byte.h b/gsl/gsl_byte.h similarity index 100% rename from include/gsl_byte.h rename to gsl/gsl_byte.h diff --git a/include/gsl_util.h b/gsl/gsl_util.h similarity index 100% rename from include/gsl_util.h rename to gsl/gsl_util.h diff --git a/include/multi_span.h b/gsl/multi_span.h similarity index 100% rename from include/multi_span.h rename to gsl/multi_span.h diff --git a/include/span.h b/gsl/span.h similarity index 100% rename from include/span.h rename to gsl/span.h diff --git a/include/string_span.h b/gsl/string_span.h similarity index 100% rename from include/string_span.h rename to gsl/string_span.h diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 79931f7..4a59470 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -9,7 +9,7 @@ endif() add_subdirectory(unittest-cpp) include_directories( - ../include + .. ./unittest-cpp ) @@ -33,7 +33,7 @@ else() endif() 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.h ../gsl/gsl_assert.h ../gsl/gsl_util.h ../gsl/multi_span.h ../gsl/span.h ../gsl/string_span.h) target_link_libraries(${name} UnitTest++) install(TARGETS ${name} RUNTIME DESTINATION bin diff --git a/tests/assertion_tests.cpp b/tests/assertion_tests.cpp index acd381a..4ac1856 100644 --- a/tests/assertion_tests.cpp +++ b/tests/assertion_tests.cpp @@ -15,7 +15,7 @@ /////////////////////////////////////////////////////////////////////////////// #include -#include +#include using namespace gsl; diff --git a/tests/at_tests.cpp b/tests/at_tests.cpp index 1a9f814..53d93d1 100644 --- a/tests/at_tests.cpp +++ b/tests/at_tests.cpp @@ -15,7 +15,7 @@ /////////////////////////////////////////////////////////////////////////////// #include -#include +#include #include #include diff --git a/tests/bounds_tests.cpp b/tests/bounds_tests.cpp index 736a85c..7d5a071 100644 --- a/tests/bounds_tests.cpp +++ b/tests/bounds_tests.cpp @@ -15,7 +15,7 @@ /////////////////////////////////////////////////////////////////////////////// #include -#include +#include #include using namespace std; diff --git a/tests/byte_tests.cpp b/tests/byte_tests.cpp index 5d4e7f6..183bebf 100644 --- a/tests/byte_tests.cpp +++ b/tests/byte_tests.cpp @@ -15,7 +15,7 @@ /////////////////////////////////////////////////////////////////////////////// #include -#include +#include #include #include diff --git a/tests/multi_span_tests.cpp b/tests/multi_span_tests.cpp index 003d236..b2e5b5f 100644 --- a/tests/multi_span_tests.cpp +++ b/tests/multi_span_tests.cpp @@ -15,7 +15,7 @@ /////////////////////////////////////////////////////////////////////////////// #include -#include +#include #include #include diff --git a/tests/notnull_tests.cpp b/tests/notnull_tests.cpp index 67b478a..bc12e9b 100644 --- a/tests/notnull_tests.cpp +++ b/tests/notnull_tests.cpp @@ -15,7 +15,7 @@ /////////////////////////////////////////////////////////////////////////////// #include -#include +#include #include using namespace gsl; diff --git a/tests/owner_tests.cpp b/tests/owner_tests.cpp index 47c223a..3c82022 100644 --- a/tests/owner_tests.cpp +++ b/tests/owner_tests.cpp @@ -15,7 +15,7 @@ /////////////////////////////////////////////////////////////////////////////// #include -#include +#include #include using namespace gsl; diff --git a/tests/span_tests.cpp b/tests/span_tests.cpp index 8c9829d..fb20f77 100644 --- a/tests/span_tests.cpp +++ b/tests/span_tests.cpp @@ -15,7 +15,7 @@ /////////////////////////////////////////////////////////////////////////////// #include -#include +#include #include #include diff --git a/tests/strided_span_tests.cpp b/tests/strided_span_tests.cpp index b81a5e7..4c07670 100644 --- a/tests/strided_span_tests.cpp +++ b/tests/strided_span_tests.cpp @@ -15,7 +15,7 @@ /////////////////////////////////////////////////////////////////////////////// #include -#include +#include #include #include diff --git a/tests/string_span_tests.cpp b/tests/string_span_tests.cpp index 876886a..fbaa9e8 100644 --- a/tests/string_span_tests.cpp +++ b/tests/string_span_tests.cpp @@ -16,7 +16,7 @@ #include #include -#include +#include #include using namespace std; diff --git a/tests/utils_tests.cpp b/tests/utils_tests.cpp index 11582de..8c98223 100644 --- a/tests/utils_tests.cpp +++ b/tests/utils_tests.cpp @@ -15,7 +15,7 @@ /////////////////////////////////////////////////////////////////////////////// #include -#include +#include #include using namespace gsl; From f9f08a56fa08addbd96ab90430735e4e044a3af1 Mon Sep 17 00:00:00 2001 From: Neil MacIntosh Date: Tue, 9 Aug 2016 18:07:17 -0700 Subject: [PATCH 3/4] Added test for Issue #305. --- tests/string_span_tests.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tests/string_span_tests.cpp b/tests/string_span_tests.cpp index 876886a..ca60e4b 100644 --- a/tests/string_span_tests.cpp +++ b/tests/string_span_tests.cpp @@ -18,6 +18,7 @@ #include #include #include +#include using namespace std; using namespace gsl; @@ -942,7 +943,13 @@ SUITE(string_span_tests) CHECK(*(str + 3) == L'\0'); } } + } + TEST(Issue305) + { + std::map, int> foo = { { "foo", 0 },{ "bar", 1 } }; + CHECK(foo["foo"] == 0); + CHECK(foo["bar"] == 1); } } From 222c2d85fd2ab37128f5cf00d5267489ea2a8625 Mon Sep 17 00:00:00 2001 From: Galik Date: Wed, 10 Aug 2016 17:24:00 +0100 Subject: [PATCH 4/4] Removed .h extension from header files. --- CMakeLists.txt | 8 ++++---- README.md | 7 +++---- gsl/{gsl.h => gsl} | 10 +++++----- gsl/{gsl_assert.h => gsl_assert} | 0 gsl/{gsl_byte.h => gsl_byte} | 0 gsl/{gsl_util.h => gsl_util} | 2 +- gsl/{multi_span.h => multi_span} | 6 +++--- gsl/{span.h => span} | 6 +++--- gsl/{string_span.h => string_span} | 6 +++--- tests/CMakeLists.txt | 2 +- tests/assertion_tests.cpp | 2 +- tests/at_tests.cpp | 2 +- tests/bounds_tests.cpp | 2 +- tests/byte_tests.cpp | 2 +- tests/multi_span_tests.cpp | 2 +- tests/notnull_tests.cpp | 2 +- tests/owner_tests.cpp | 2 +- tests/span_tests.cpp | 2 +- tests/strided_span_tests.cpp | 2 +- tests/string_span_tests.cpp | 2 +- tests/utils_tests.cpp | 2 +- 21 files changed, 34 insertions(+), 35 deletions(-) rename gsl/{gsl.h => gsl} (94%) rename gsl/{gsl_assert.h => gsl_assert} (100%) rename gsl/{gsl_byte.h => gsl_byte} (100%) rename gsl/{gsl_util.h => gsl_util} (98%) rename gsl/{multi_span.h => multi_span} (99%) rename gsl/{span.h => span} (99%) rename gsl/{string_span.h => string_span} (99%) diff --git a/CMakeLists.txt b/CMakeLists.txt index ba85857..cb5911c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,10 +3,10 @@ cmake_minimum_required(VERSION 2.8.7) project(GSL CXX) set(GSL_HEADERS - "gsl/gsl.h" - "gsl/gsl_assert.h" - "gsl/span.h" - "gsl/string_span.h" + "gsl/gsl" + "gsl/gsl_assert" + "gsl/span" + "gsl/string_span" ) include_directories( diff --git a/README.md b/README.md index f54b0c5..58bb46c 100644 --- a/README.md +++ b/README.md @@ -8,8 +8,8 @@ The library includes types like `span`, `string_span`, `owner<>` and others. 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. [gsl/span.h](./gsl/span.h)), -it is simplest to just include [gsl/gsl.h](./gsl/gsl.h) and gain access to the entire library. +While some types have been broken out into their own headers (e.g. [gsl/span](./gsl/span)), +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 other platforms. Please see [CONTRIBUTING.md](./CONTRIBUTING.md) for more information about contributing. @@ -78,8 +78,7 @@ MSVC++ GCC/clang -I$HOME/dev/GSL - Include the library using: - #include + #include diff --git a/gsl/gsl.h b/gsl/gsl similarity index 94% rename from gsl/gsl.h rename to gsl/gsl index 8e00a44..656ebe0 100644 --- a/gsl/gsl.h +++ b/gsl/gsl @@ -19,11 +19,11 @@ #ifndef GSL_GSL_H #define GSL_GSL_H -#include "gsl_assert.h" // Ensures/Expects -#include "gsl_util.h" // finally()/narrow()/narrow_cast()... -#include "multi_span.h" // multi_span, strided_span... -#include "span.h" // span -#include "string_span.h" // zstring, string_span, zstring_builder... +#include "gsl_assert" // Ensures/Expects +#include "gsl_util" // finally()/narrow()/narrow_cast()... +#include "multi_span" // multi_span, strided_span... +#include "span" // span +#include "string_span" // zstring, string_span, zstring_builder... #include #ifdef _MSC_VER diff --git a/gsl/gsl_assert.h b/gsl/gsl_assert similarity index 100% rename from gsl/gsl_assert.h rename to gsl/gsl_assert diff --git a/gsl/gsl_byte.h b/gsl/gsl_byte similarity index 100% rename from gsl/gsl_byte.h rename to gsl/gsl_byte diff --git a/gsl/gsl_util.h b/gsl/gsl_util similarity index 98% rename from gsl/gsl_util.h rename to gsl/gsl_util index 92a795b..4a0dabe 100644 --- a/gsl/gsl_util.h +++ b/gsl/gsl_util @@ -19,7 +19,7 @@ #ifndef GSL_UTIL_H #define GSL_UTIL_H -#include "gsl_assert.h" // Ensures/Expects +#include "gsl_assert" // Ensures/Expects #include #include #include diff --git a/gsl/multi_span.h b/gsl/multi_span similarity index 99% rename from gsl/multi_span.h rename to gsl/multi_span index c883fb0..fcc53b8 100644 --- a/gsl/multi_span.h +++ b/gsl/multi_span @@ -19,9 +19,9 @@ #ifndef GSL_MULTI_SPAN_H #define GSL_MULTI_SPAN_H -#include "gsl_assert.h" -#include "gsl_byte.h" -#include "gsl_util.h" +#include "gsl_assert" +#include "gsl_byte" +#include "gsl_util" #include #include #include diff --git a/gsl/span.h b/gsl/span similarity index 99% rename from gsl/span.h rename to gsl/span index 1405aa9..b6a2f6d 100644 --- a/gsl/span.h +++ b/gsl/span @@ -20,9 +20,9 @@ #ifndef GSL_SPAN_H #define GSL_SPAN_H -#include "gsl_assert.h" -#include "gsl_byte.h" -#include "gsl_util.h" +#include "gsl_assert" +#include "gsl_byte" +#include "gsl_util" #include #include #include diff --git a/gsl/string_span.h b/gsl/string_span similarity index 99% rename from gsl/string_span.h rename to gsl/string_span index e18e07a..fa3d2ff 100644 --- a/gsl/string_span.h +++ b/gsl/string_span @@ -19,9 +19,9 @@ #ifndef GSL_STRING_SPAN_H #define GSL_STRING_SPAN_H -#include "gsl_assert.h" -#include "gsl_util.h" -#include "span.h" +#include "gsl_assert" +#include "gsl_util" +#include "span" #include #include #include diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 4a59470..3c3125e 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -33,7 +33,7 @@ else() endif() function(add_gsl_test name) - add_executable(${name} ${name}.cpp ../gsl/gsl.h ../gsl/gsl_assert.h ../gsl/gsl_util.h ../gsl/multi_span.h ../gsl/span.h ../gsl/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++) install(TARGETS ${name} RUNTIME DESTINATION bin diff --git a/tests/assertion_tests.cpp b/tests/assertion_tests.cpp index 4ac1856..a251200 100644 --- a/tests/assertion_tests.cpp +++ b/tests/assertion_tests.cpp @@ -15,7 +15,7 @@ /////////////////////////////////////////////////////////////////////////////// #include -#include +#include using namespace gsl; diff --git a/tests/at_tests.cpp b/tests/at_tests.cpp index 53d93d1..008fddf 100644 --- a/tests/at_tests.cpp +++ b/tests/at_tests.cpp @@ -15,7 +15,7 @@ /////////////////////////////////////////////////////////////////////////////// #include -#include +#include #include #include diff --git a/tests/bounds_tests.cpp b/tests/bounds_tests.cpp index 7d5a071..d10bf6d 100644 --- a/tests/bounds_tests.cpp +++ b/tests/bounds_tests.cpp @@ -15,7 +15,7 @@ /////////////////////////////////////////////////////////////////////////////// #include -#include +#include #include using namespace std; diff --git a/tests/byte_tests.cpp b/tests/byte_tests.cpp index 183bebf..f2f8026 100644 --- a/tests/byte_tests.cpp +++ b/tests/byte_tests.cpp @@ -15,7 +15,7 @@ /////////////////////////////////////////////////////////////////////////////// #include -#include +#include #include #include diff --git a/tests/multi_span_tests.cpp b/tests/multi_span_tests.cpp index b2e5b5f..f04ba84 100644 --- a/tests/multi_span_tests.cpp +++ b/tests/multi_span_tests.cpp @@ -15,7 +15,7 @@ /////////////////////////////////////////////////////////////////////////////// #include -#include +#include #include #include diff --git a/tests/notnull_tests.cpp b/tests/notnull_tests.cpp index bc12e9b..526b074 100644 --- a/tests/notnull_tests.cpp +++ b/tests/notnull_tests.cpp @@ -15,7 +15,7 @@ /////////////////////////////////////////////////////////////////////////////// #include -#include +#include #include using namespace gsl; diff --git a/tests/owner_tests.cpp b/tests/owner_tests.cpp index 3c82022..6680981 100644 --- a/tests/owner_tests.cpp +++ b/tests/owner_tests.cpp @@ -15,7 +15,7 @@ /////////////////////////////////////////////////////////////////////////////// #include -#include +#include #include using namespace gsl; diff --git a/tests/span_tests.cpp b/tests/span_tests.cpp index fb20f77..8479aa1 100644 --- a/tests/span_tests.cpp +++ b/tests/span_tests.cpp @@ -15,7 +15,7 @@ /////////////////////////////////////////////////////////////////////////////// #include -#include +#include #include #include diff --git a/tests/strided_span_tests.cpp b/tests/strided_span_tests.cpp index 4c07670..86666d1 100644 --- a/tests/strided_span_tests.cpp +++ b/tests/strided_span_tests.cpp @@ -15,7 +15,7 @@ /////////////////////////////////////////////////////////////////////////////// #include -#include +#include #include #include diff --git a/tests/string_span_tests.cpp b/tests/string_span_tests.cpp index 3eeacb0..7e623f3 100644 --- a/tests/string_span_tests.cpp +++ b/tests/string_span_tests.cpp @@ -16,7 +16,7 @@ #include #include -#include +#include #include #include diff --git a/tests/utils_tests.cpp b/tests/utils_tests.cpp index 8c98223..9f4ba02 100644 --- a/tests/utils_tests.cpp +++ b/tests/utils_tests.cpp @@ -15,7 +15,7 @@ /////////////////////////////////////////////////////////////////////////////// #include -#include +#include #include using namespace gsl;