{"id":595,"date":"2022-02-04T14:51:57","date_gmt":"2022-02-04T14:51:57","guid":{"rendered":"https:\/\/tbekk.com\/devstream\/?p=595"},"modified":"2022-02-04T15:00:05","modified_gmt":"2022-02-04T15:00:05","slug":"gsl-4-0-0-is-available-now","status":"publish","type":"post","link":"https:\/\/tbekk.com\/devstream\/2022\/02\/04\/gsl-4-0-0-is-available-now\/","title":{"rendered":"GSL 4.0.0 is Available Now"},"content":{"rendered":"\n<hr class=\"wp-block-separator is-style-wide\"\/>\n\n\n\n<ul class=\"wp-block-list\" id=\"block-1bf21edb-b66a-4de0-9e00-86d868b8ffb2\"><li><em><strong>Link:<\/strong><a href=\"https:\/\/www.qt.io\/blog\/simplifying-the-commercial-licensing-portfolio?utm_campaign=Subscription%20Conversion%2022&amp;utm_content=196294752&amp;utm_medium=social&amp;utm_source=twitter&amp;hss_channel=tw-64366556\"> <\/a><a href=\"https:\/\/devblogs.microsoft.com\/cppblog\/gsl-4-0-0-is-available-now\/\">https:\/\/devblogs.microsoft.com\/cppblog\/gsl-4-0-0-is-available-now\/<\/a><\/em><\/li><li><em><strong>Publication Date:<\/strong> Friday February 04, 2022<\/em><\/li><li><em><strong>Author:\u00a0<\/strong><\/em><a href=\"https:\/\/devblogs.microsoft.com\/cppblog\/gsl-4-0-0-is-available-now\/\"><em>Dmitry Kobets<\/em><\/a><\/li><li><em><strong>Github<\/strong>:<a rel=\"noreferrer noopener\" href=\"https:\/\/github.com\/microsoft\/GSL\" target=\"_blank\"> GSL GitHub page<\/a><\/em><\/li><\/ul>\n\n\n\n<hr class=\"wp-block-separator is-style-wide\"\/>\n\n\n\n<p>Version 4.0.0 of Microsoft\u2019s implementation of the&nbsp;<a href=\"https:\/\/github.com\/microsoft\/GSL\" target=\"_blank\" rel=\"noreferrer noopener\">C++ Core Guidelines Support Library<\/a>&nbsp;(GSL) is now available for you to download on the&nbsp;<a href=\"https:\/\/github.com\/microsoft\/gsl\/releases\" target=\"_blank\" rel=\"noreferrer noopener\">releases page<\/a>. This release maintains the safety guarantees that we have always offered and adds improvements to various parts of the library.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"what-changed-in-this-release\">What changed in this release?<\/h2>\n\n\n\n<ul class=\"wp-block-list\"><li><a href=\"https:\/\/devblogs.microsoft.com\/cppblog\/gsl-4-0-0-is-available-now\/#deprecation-of-gslstring_span\">Deprecation of&nbsp;<code>gsl::string_span<\/code><\/a><\/li><li><a href=\"https:\/\/devblogs.microsoft.com\/cppblog\/gsl-4-0-0-is-available-now\/#removal-of-gsl-multi_span\">Removal of&nbsp;<code>&lt;gsl\/multi_span&gt;<\/code><\/a><\/li><li><a href=\"https:\/\/devblogs.microsoft.com\/cppblog\/gsl-4-0-0-is-available-now\/#header-files-dropped-the-gsl_-prefix\">Header files dropped the&nbsp;<code>gsl_<\/code>&nbsp;prefix<\/a><\/li><li><a href=\"https:\/\/devblogs.microsoft.com\/cppblog\/gsl-4-0-0-is-available-now\/#changes-to-not_null\">Changes to&nbsp;<code>not_null<\/code><\/a><\/li><li><a href=\"https:\/\/devblogs.microsoft.com\/cppblog\/gsl-4-0-0-is-available-now\/#gslspan-and-stdspan-now-use-the-correct-specialization-of-gslat\"><code>gsl::span<\/code>&nbsp;and&nbsp;<code>std::span<\/code>&nbsp;now use the correct specialization of&nbsp;<code>gsl::at<\/code><\/a><\/li><li>The&nbsp;<code>zstring<\/code>&nbsp;family no longer requires empty brackets to be used:&nbsp;<a href=\"https:\/\/github.com\/microsoft\/GSL\/issues\/992\" target=\"_blank\" rel=\"noreferrer noopener\">issue#992<\/a><ul><li>for example,&nbsp;<code>void&nbsp;foo(zstring&lt;&gt;&nbsp;str);<\/code>&nbsp;should now be&nbsp;<code>void&nbsp;foo(zstring str);<\/code><\/li><\/ul><\/li><li><code>gsl::narrowing_error<\/code>&nbsp;now has a helpful&nbsp;<code>what()<\/code>&nbsp;message<\/li><li><code>finally<\/code>&nbsp;and&nbsp;<code>final_action<\/code>&nbsp;are now&nbsp;<code>[[nodiscard]]<\/code><\/li><li><a href=\"https:\/\/devblogs.microsoft.com\/cppblog\/gsl-4-0-0-is-available-now\/#gsl-will-work-in-environments-where-exceptions-are-disabled-with-some-caveats\">GSL will work in environments where exceptions are disabled, with some caveats<\/a><\/li><li>GSL will work in environments which do not support iostreams, via the addition of the&nbsp;<code>GSL_NO_IOSTREAMS<\/code>&nbsp;flag:&nbsp;<a href=\"https:\/\/github.com\/microsoft\/GSL\/pull\/935\" target=\"_blank\" rel=\"noreferrer noopener\">#953<\/a><\/li><li><a href=\"https:\/\/devblogs.microsoft.com\/cppblog\/gsl-4-0-0-is-available-now\/#C-compilers\">Updated compiler support<\/a><\/li><li><a href=\"https:\/\/devblogs.microsoft.com\/cppblog\/gsl-4-0-0-is-available-now\/#cmake-and-build-improvements\">CMake and build improvements<\/a><\/li><\/ul>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"deprecation-of-gslstring_span\">Deprecation of&nbsp;<code>gsl::string_span<\/code><\/h2>\n\n\n\n<p><a href=\"https:\/\/github.com\/isocpp\/CppCoreGuidelines\/pull\/1680\" target=\"_blank\" rel=\"noreferrer noopener\">isocpp\/CppCoreGuidelines#1680<\/a>&nbsp;removed&nbsp;<code>string_span<\/code>&nbsp;from the C++ Core Guidelines. The recommendation is to use&nbsp;<code>std::string_view<\/code>,&nbsp;<code>std::span&lt;char&gt;<\/code>&nbsp;or&nbsp;<code>gsl::span&lt;char&gt;<\/code>&nbsp;instead. To more closely align Microsoft\u2019s GSL with the C++ Core Guidelines, we deprecated our implementation of&nbsp;<code>string_span<\/code>&nbsp;and&nbsp;<code>zstring_span<\/code>, including&nbsp;<code>basic_string_span<\/code>,&nbsp;<code>basic_zstring_span<\/code>, and all related types. For the time being, we will continue to provide the&nbsp;<code>&lt;gsl\/string_span&gt;<\/code>&nbsp;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&nbsp;<a href=\"https:\/\/github.com\/microsoft\/GSL\/blob\/main\/README.md\" target=\"_blank\" rel=\"noreferrer noopener\">README.md<\/a>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"removal-of-gsl-multi_span\">Removal of&nbsp;<code>&lt;gsl\/multi_span&gt;<\/code><\/h2>\n\n\n\n<p><code>multi_span<\/code>,&nbsp;<code>strided_span<\/code>, and everything else in&nbsp;<code>&lt;gsl\/multi_span&gt;<\/code>&nbsp;were deprecated over a year ago in&nbsp;<a href=\"https:\/\/github.com\/microsoft\/GSL\/releases\/tag\/v3.0.0\" target=\"_blank\" rel=\"noreferrer noopener\">GSL 3.0.0<\/a>, and it is time for them and their associated tests to be removed from the library.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"header-files-dropped-the-gsl_-prefix\">Header files dropped the&nbsp;<code>gsl_<\/code>&nbsp;prefix<\/h2>\n\n\n\n<p>All headers which previously contained a&nbsp;<code>gsl_<\/code>&nbsp;prefix in their name have had this prefix removed. For example,&nbsp;<code>&lt;gsl\/gsl_algorithm&gt;<\/code>&nbsp;is now&nbsp;<code>&lt;gsl\/algorithm&gt;<\/code>. The&nbsp;<code>gsl_<\/code>&nbsp;prefixed files still exist and pass through to the updated files, but will be removed in a future release.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"changes-to-not_null\">Changes to&nbsp;<code>not_null<\/code><\/h2>\n\n\n\n<p>To more closely align Microsoft\u2019s GSL with the C++ Core Guidelines,&nbsp;<code>gsl::not_null<\/code>&nbsp;now accepts only types which are&nbsp;<em>comparable<\/em>&nbsp;to&nbsp;<code>nullptr<\/code>. Previously, it accepted only types which are&nbsp;<em>assignable<\/em>&nbsp;from&nbsp;<code>nullptr<\/code>, but this was stricter than what was intended by the&nbsp;<a href=\"http:\/\/isocpp.github.io\/CppCoreGuidelines\/CppCoreGuidelines#gslview-views\" target=\"_blank\" rel=\"noreferrer noopener\">Core Guidelines<\/a>.<\/p>\n\n\n\n<p>The functions&nbsp;<code>make_not_null<\/code>&nbsp;and&nbsp;<code>make_strict_not_null<\/code>, and the&nbsp;<code>not_null<\/code>&nbsp;comparison operators, are now all&nbsp;<code>noexcept<\/code>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"gslspan-and-stdspan-now-use-the-correct-specialization-of-gslat\"><code>gsl::span<\/code>&nbsp;and&nbsp;<code>std::span<\/code>&nbsp;now use the correct specialization of&nbsp;<code>gsl::at<\/code><\/h2>\n\n\n\n<p><code>gsl::span<\/code>&nbsp;and&nbsp;<code>std::span<\/code>&nbsp;now have their own separate specializations of&nbsp;<code>gsl::at<\/code>, to ensure consistent behavior between the two versions of span. Both overloads are included when importing&nbsp;<code>&lt;gsl\/span&gt;<\/code>. The&nbsp;<code>std::span<\/code>&nbsp;overload can be separately included from&nbsp;<code>&lt;gsl\/util&gt;<\/code>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"gsl-will-work-in-environments-where-exceptions-are-disabled-with-some-caveats\">GSL will work in environments where exceptions are disabled, with some caveats<\/h2>\n\n\n\n<p><code>gsl::narrow<\/code>&nbsp;is the only part of the library which may throw exceptions and has been moved into its own header&nbsp;<code>&lt;gsl\/narrow&gt;<\/code>. This header is included in&nbsp;<code>&lt;gsl\/gsl&gt;<\/code>&nbsp;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.<\/p>\n\n\n\n<p>Note:&nbsp;<code>gsl::narrow_cast<\/code>&nbsp;is still in&nbsp;<code>&lt;gsl\/util&gt;<\/code>, since it does not throw exceptions.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"updated-compiler-support\">Updated compiler support<\/h2>\n\n\n\n<p>The list of supported compilers\/toolsets has been updated with newer versions. More info on compiler support can be found in the&nbsp;<a href=\"https:\/\/github.com\/microsoft\/GSL\/blob\/main\/README.md#supported-compilers--toolsets\" target=\"_blank\" rel=\"noreferrer noopener\">README.md<\/a>.<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>Compiler\/Toolset<\/th><th>Version<\/th><\/tr><\/thead><tbody><tr><td>XCode<\/td><td>13.2.1 &amp; 12.5.1<\/td><\/tr><tr><td>GCC<\/td><td>11.1.0 &amp; 10.3.0<\/td><\/tr><tr><td>Clang<\/td><td>12.0.0 &amp; 11.0.0<\/td><\/tr><tr><td>Visual Studio with MSVC<\/td><td>VS2022 (17.0) &amp; VS2019 (16.11)<\/td><\/tr><tr><td>Visual Studio with LLVM<\/td><td>VS2022 (17.0) &amp; VS2019 (16.11)<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"cmake-and-build-improvements\">CMake and build improvements<\/h2>\n\n\n\n<ul class=\"wp-block-list\"><li>GSL Install logic is now guarded by a cmake option&nbsp;<code>GSL_INSTALL<\/code>:&nbsp;<a href=\"https:\/\/github.com\/microsoft\/GSL\/pull\/964\" target=\"_blank\" rel=\"noreferrer noopener\">#964<\/a><\/li><li>Fix bug which prevented the library from being built on a 32-bit host and then being used on a 64-bit machine:&nbsp;<a href=\"https:\/\/github.com\/microsoft\/GSL\/pull\/893\" target=\"_blank\" rel=\"noreferrer noopener\">#893<\/a><\/li><li>Build will now use&nbsp;<code>CMAKE_CXX_STANDARD<\/code>&nbsp;if it\u2019s provided&nbsp;<a href=\"https:\/\/github.com\/microsoft\/GSL\/pull\/953\" target=\"_blank\" rel=\"noreferrer noopener\">#953<\/a><\/li><li>Clean up&nbsp;<code>GSL_SUPPRESS<\/code>&nbsp;warning for intel compilers:&nbsp;<a href=\"https:\/\/github.com\/microsoft\/GSL\/pull\/906\" target=\"_blank\" rel=\"noreferrer noopener\">#906<\/a><\/li><li>Fix build failure for C++20 compilers which don\u2019t have&nbsp;<code>std::span<\/code>:&nbsp;<a href=\"https:\/\/github.com\/microsoft\/GSL\/pull\/993\" target=\"_blank\" rel=\"noreferrer noopener\">#993<\/a><\/li><li>Cleaned up some static analysis warnings<\/li><li>The cmake cache variable&nbsp;<code>VS_ADD_NATIVE_VISUALIZERS<\/code>&nbsp;has been renamed to&nbsp;<code>GSL_VS_ADD_NATIVE_VISUALIZERS<\/code>:&nbsp;<a href=\"https:\/\/github.com\/microsoft\/GSL\/pull\/941\" target=\"_blank\" rel=\"noreferrer noopener\">#941<\/a><\/li><\/ul>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"summary\">Summary<\/h2>\n\n\n\n<p>This has been a list of the changes in the GSL 4.0.0 release. You can download the code at the&nbsp;<a href=\"https:\/\/github.com\/microsoft\/GSL\" target=\"_blank\" rel=\"noreferrer noopener\">GSL GitHub page<\/a>. Please stay tuned for future releases!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Link: https:\/\/devblogs.microsoft.com\/cppblog\/gsl-4-0-0-is-available-now\/ Publication Date: Friday February 04, 2022 Author:\u00a0Dmitry Kobets Github: GSL GitHub page Version 4.0.0 of Microsoft\u2019s implementation of the&nbsp;C++ Core Guidelines Support Library&nbsp;(GSL) is now available for you&#8230; <a class=\"read-more-link\" href=\"https:\/\/tbekk.com\/devstream\/2022\/02\/04\/gsl-4-0-0-is-available-now\/\">Read more &raquo;<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[10,9],"tags":[134],"class_list":["post-595","post","type-post","status-publish","format-standard","hentry","category-development","category-news","tag-guideline"],"_links":{"self":[{"href":"https:\/\/tbekk.com\/devstream\/wp-json\/wp\/v2\/posts\/595","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/tbekk.com\/devstream\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/tbekk.com\/devstream\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/tbekk.com\/devstream\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/tbekk.com\/devstream\/wp-json\/wp\/v2\/comments?post=595"}],"version-history":[{"count":3,"href":"https:\/\/tbekk.com\/devstream\/wp-json\/wp\/v2\/posts\/595\/revisions"}],"predecessor-version":[{"id":598,"href":"https:\/\/tbekk.com\/devstream\/wp-json\/wp\/v2\/posts\/595\/revisions\/598"}],"wp:attachment":[{"href":"https:\/\/tbekk.com\/devstream\/wp-json\/wp\/v2\/media?parent=595"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/tbekk.com\/devstream\/wp-json\/wp\/v2\/categories?post=595"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/tbekk.com\/devstream\/wp-json\/wp\/v2\/tags?post=595"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}