GSL 4.0.0 is Available Now
Version 4.0.0 of Microsoft’s implementation of the C++ Core Guidelines Support Library (GSL) is now available for you to download on the releases page. This release maintains the safety guarantees that we have always offered and adds improvements to various parts of the library.
What changed in this release?
- Deprecation of
- Removal of
- Header files dropped the
- Changes to
std::spannow use the correct specialization of
zstringfamily no longer requires empty brackets to be used: issue#992
- for example,
void foo(zstring<> str);should now be
void foo(zstring str);
- for example,
gsl::narrowing_errornow has a helpful
- GSL will work in environments where exceptions are disabled, with some caveats
- GSL will work in environments which do not support iostreams, via the addition of the
- Updated compiler support
- CMake and build improvements
string_span from the C++ Core Guidelines. The recommendation is to use
gsl::span<char> instead. To more closely align Microsoft’s GSL with the C++ Core Guidelines, we deprecated our implementation of
basic_zstring_span, and all related types. For the time being, we will continue to provide the
<gsl/string_span> header, but it will not be actively worked on or maintained. A table of all supported and unsupported types/features can be found in the README.md.
strided_span, and everything else in
<gsl/multi_span> were deprecated over a year ago in GSL 3.0.0, and it is time for them and their associated tests to be removed from the library.
Header files dropped the
All headers which previously contained a
gsl_ prefix in their name have had this prefix removed. For example,
<gsl/gsl_algorithm> is now
gsl_ prefixed files still exist and pass through to the updated files, but will be removed in a future release.
To more closely align Microsoft’s GSL with the C++ Core Guidelines,
gsl::not_null now accepts only types which are comparable to
nullptr. Previously, it accepted only types which are assignable from
nullptr, but this was stricter than what was intended by the Core Guidelines.
make_strict_not_null, and the
not_null comparison operators, are now all
std::span now use the correct specialization of
std::span now have their own separate specializations of
gsl::at, to ensure consistent behavior between the two versions of span. Both overloads are included when importing
std::span overload can be separately included from
GSL will work in environments where exceptions are disabled, with some caveats
gsl::narrow is the only part of the library which may throw exceptions and has been moved into its own header
<gsl/narrow>. This header is included in
<gsl/gsl> only if exceptions are enabled. This allows users of the library who are working in environments without exceptions to use all of the other components of the library.
gsl::narrow_cast is still in
<gsl/util>, since it does not throw exceptions.
Updated compiler support
The list of supported compilers/toolsets has been updated with newer versions. More info on compiler support can be found in the README.md.
|XCode||13.2.1 & 12.5.1|
|GCC||11.1.0 & 10.3.0|
|Clang||12.0.0 & 11.0.0|
|Visual Studio with MSVC||VS2022 (17.0) & VS2019 (16.11)|
|Visual Studio with LLVM||VS2022 (17.0) & VS2019 (16.11)|
CMake and build improvements
- GSL Install logic is now guarded by a cmake option
- Fix bug which prevented the library from being built on a 32-bit host and then being used on a 64-bit machine: #893
- Build will now use
CMAKE_CXX_STANDARDif it’s provided #953
- Clean up
GSL_SUPPRESSwarning for intel compilers: #906
- Fix build failure for C++20 compilers which don’t have
- Cleaned up some static analysis warnings
- The cmake cache variable
VS_ADD_NATIVE_VISUALIZERShas been renamed to
This has been a list of the changes in the GSL 4.0.0 release. You can download the code at the GSL GitHub page. Please stay tuned for future releases!