{"id":35183,"date":"2025-03-06T09:36:54","date_gmt":"2025-03-06T09:36:54","guid":{"rendered":"https:\/\/devblogs.microsoft.com\/cppblog\/?p=35183"},"modified":"2025-03-06T09:36:54","modified_gmt":"2025-03-06T09:36:54","slug":"announcing-guidelines-support-library-v4-2-0","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/cppblog\/announcing-guidelines-support-library-v4-2-0\/","title":{"rendered":"Announcing Guidelines Support Library v4.2.0"},"content":{"rendered":"<p><em>GSL is an implementation of the Guidelines Support Library specified by the\n<a href=\"https:\/\/isocpp.github.io\/CppCoreGuidelines\/CppCoreGuidelines\">C++ Core Guidelines<\/a>.\nIt provides types and functions that help C++ developers write safer, more maintainable\ncode while following modern C++ best practices.<\/em><\/p>\n<p>We are excited to announce the release of GSL v4.2.0! This release brings significant\nperformance improvements, new features, and important updates that align GSL with modern\nC++ standards.<\/p>\n<h2>Performance Boost for Span Iterator<\/h2>\n<p>One of the most notable changes in this release is the significant performance\nimprovements of <code>span_iterator<\/code> when using the Clang compiler. Previously, <code>gsl::span<\/code>\niterators could be up to 20 times slower than <code>std::span<\/code> under various workloads\n(range-for, <code>&lt;algorithm&gt;<\/code>, etc.). Through reorganization of the code and moving\naccess-checks out of the hot path, we have achieved performance parity for most\nworkloads (see <a href=\"https:\/\/github.com\/Microsoft\/GSL\/issues\/1168\">#1168<\/a>). This\nABI-preserving improvement makes <code>gsl::span<\/code> a more practical choice for code that is\nboth safe and fast.<\/p>\n<h2>New Features and Improvements<\/h2>\n<p>As the C++ Core Guidelines evolve with modern C++ practices, GSL continues to adapt and\ngrow. Working closely with the community, we&#8217;ve implemented key enhancements that make\nGSL more robust and easier to use in modern C++ codebases. These updates focus on type\nsafety, modern idioms, and better template support \u2014 areas crucial for production\ncode. Here are some of the key improvements since version 4.1.0:<\/p>\n<ul>\n<li><strong>GSL Swap Support<\/strong>: Introduced <code>gsl::swap<\/code> specifically designed for safely swapping\n<code>gsl::not_null<\/code> pointers<\/li>\n<li><strong>Enhanced Type Traits<\/strong>: Added <code>element_type<\/code> to <code>gsl::not_null&lt;T&gt;<\/code> for better type\ntrait consistency<\/li>\n<li><strong>Improved Smart Pointer Support<\/strong>: Added support for <code>strict_not_null<\/code> with\n<code>unique_ptr<\/code><\/li>\n<li><strong>Better SFINAE<\/strong>: Improved template substitution behavior throughout the library<\/li>\n<\/ul>\n<h2>Alignment with C++ Standards<\/h2>\n<p>As part of our commitment to keeping GSL aligned with modern C++ development, we are\ndeprecating features that have been adopted into the C++ standard library. We recommend\nusing the C++ standard library equivalents for these features when possible. Here are\nthe features that have been deprecated in this release:<\/p>\n<ul>\n<li><code>gsl::unique_ptr<\/code><\/li>\n<li><code>gsl::shared_ptr<\/code><\/li>\n<li><code>gsl::byte<\/code> (for C++17 and later)<\/li>\n<\/ul>\n<p>Additionally, we have removed the long-deprecated <code>string_span<\/code> feature, encouraging\nusers to migrate to <code>std::string_view<\/code>.<\/p>\n<p><strong>Note:<\/strong> We continue to recommend using <code>gsl::span<\/code> as a safer alternative to\n<code>std::span<\/code>.<\/p>\n<h2>Compatibility Updates<\/h2>\n<p>We want to make sure GSL runs well on the latest compilers and modern operating systems.\nTo that end, we have modernized our build infrastructure to validate that GSL is\nsupported by the latest development environments:<\/p>\n<ul>\n<li>Updated compiler support to include Clang 16 to 18 and GCC 12 to 14<\/li>\n<li>Upgraded to Ubuntu 24.04 in our CI pipeline<\/li>\n<\/ul>\n<p>More information about our supported platforms can be found in our\n<a href=\"https:\/\/github.com\/Microsoft\/GSL\/blob\/main\/README.md\">README<\/a>.<\/p>\n<h2>Bug Fixes and Standards Compliance<\/h2>\n<p>Several important bugs have been fixed in this release:<\/p>\n<ul>\n<li>Resolved a GCC-specific issue with list initialization of const references<\/li>\n<li>Fixed SFINAE implementation in <code>gsl::owner<\/code><\/li>\n<li>Improved include directive handling to prevent conflicts with standard library headers<\/li>\n<li>Updated include paths to comply with C++ Core Guidelines<\/li>\n<\/ul>\n<h2>Try It Out<\/h2>\n<p>To start using GSL v4.2.0, you can either:<\/p>\n<ol>\n<li>Install via vcpkg: <code>vcpkg install ms-gsl<\/code><\/li>\n<li>Download from GitHub:\n<a href=\"https:\/\/github.com\/microsoft\/GSL\/releases\/tag\/v4.2.0\">microsoft\/GSL<\/a><\/li>\n<\/ol>\n<p>For detailed release notes and migration guidance, please visit our\n<a href=\"https:\/\/github.com\/microsoft\/GSL\/releases\">GitHub repository<\/a>.<\/p>\n<h2>Contributing to GSL<\/h2>\n<p>This release would not have been possible without our community contributors. Special\nthanks to the following individuals for their valuable contributions:<\/p>\n<ul>\n<li><a href=\"https:\/\/github.com\/ajtruckle\">@ajtruckle<\/a><\/li>\n<li><a href=\"https:\/\/github.com\/apenn-msft\">@apenn-msft<\/a><\/li>\n<li><a href=\"https:\/\/github.com\/asartori86\">@asartori86<\/a><\/li>\n<li><a href=\"https:\/\/github.com\/beinhaerter\">@beinhaerter<\/a><\/li>\n<li><a href=\"https:\/\/github.com\/daltairwalter\">@daltairwalter<\/a><\/li>\n<li><a href=\"https:\/\/github.com\/DanielJump\">@DanielJump<\/a><\/li>\n<li><a href=\"https:\/\/github.com\/HenryHu\">@HenryHu<\/a><\/li>\n<li><a href=\"https:\/\/github.com\/lord-pando\">@lord-pando<\/a><\/li>\n<li><a href=\"https:\/\/github.com\/mhthies\">@mhthies<\/a><\/li>\n<li><a href=\"https:\/\/github.com\/paparodeo\">@paparodeo<\/a><\/li>\n<li><a href=\"https:\/\/github.com\/tiagomacarios\">@tiagomacarios<\/a><\/li>\n<\/ul>\n<p>If you wish to contribute to GSL, please refer to our open issues and pull requests in\nthe <a href=\"https:\/\/github.com\/microsoft\/GSL\">Microsoft\/GSL<\/a> repository on GitHub. We welcome\nyour feedback and contributions!<\/p>\n<p><em>Please remember to follow our\n<a href=\"https:\/\/opensource.microsoft.com\/codeofconduct\">Code of Conduct<\/a> when contributing to\nGSL.<\/em><\/p>\n<h2>Feedback<\/h2>\n<p>In addition to contributing, we would love to hear your thoughts on the latest updates\nto GSL! Please share your feedback and suggestions in the comments below.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Version 4.2.0 of Microsoft&#8217;s Guidelines Support Library brings performance improvements, safety features, modern compiler support.<\/p>\n","protected":false},"author":169849,"featured_media":35994,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[270,1],"tags":[],"class_list":["post-35183","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-announcement","category-cplusplus"],"acf":[],"blog_post_summary":"<p>Version 4.2.0 of Microsoft&#8217;s Guidelines Support Library brings performance improvements, safety features, modern compiler support.<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/posts\/35183","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/users\/169849"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/comments?post=35183"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/posts\/35183\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/media\/35994"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/media?parent=35183"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/categories?post=35183"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/tags?post=35183"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}