GSL is an implementation of the Guidelines Support Library specified by the C++ Core Guidelines. It provides types and functions that help C++ developers write safer, more maintainable code while following modern C++ best practices.
We are excited to announce the release of GSL v4.2.0! This release brings significant performance improvements, new features, and important updates that align GSL with modern C++ standards.
Performance Boost for Span Iterator
One of the most notable changes in this release is the significant performance
improvements of span_iterator
when using the Clang compiler. Previously, gsl::span
iterators could be up to 20 times slower than std::span
under various workloads
(range-for, <algorithm>
, etc.). Through reorganization of the code and moving
access-checks out of the hot path, we have achieved performance parity for most
workloads (see #1168). This
ABI-preserving improvement makes gsl::span
a more practical choice for code that is
both safe and fast.
New Features and Improvements
As the C++ Core Guidelines evolve with modern C++ practices, GSL continues to adapt and grow. Working closely with the community, we’ve implemented key enhancements that make GSL more robust and easier to use in modern C++ codebases. These updates focus on type safety, modern idioms, and better template support — areas crucial for production code. Here are some of the key improvements since version 4.1.0:
- GSL Swap Support: Introduced
gsl::swap
specifically designed for safely swappinggsl::not_null
pointers - Enhanced Type Traits: Added
element_type
togsl::not_null<T>
for better type trait consistency - Improved Smart Pointer Support: Added support for
strict_not_null
withunique_ptr
- Better SFINAE: Improved template substitution behavior throughout the library
Alignment with C++ Standards
As part of our commitment to keeping GSL aligned with modern C++ development, we are deprecating features that have been adopted into the C++ standard library. We recommend using the C++ standard library equivalents for these features when possible. Here are the features that have been deprecated in this release:
gsl::unique_ptr
gsl::shared_ptr
gsl::byte
(for C++17 and later)
Additionally, we have removed the long-deprecated string_span
feature, encouraging
users to migrate to std::string_view
.
Note: We continue to recommend using gsl::span
as a safer alternative to
std::span
.
Compatibility Updates
We want to make sure GSL runs well on the latest compilers and modern operating systems. To that end, we have modernized our build infrastructure to validate that GSL is supported by the latest development environments:
- Updated compiler support to include Clang 16 to 18 and GCC 12 to 14
- Upgraded to Ubuntu 24.04 in our CI pipeline
More information about our supported platforms can be found in our README.
Bug Fixes and Standards Compliance
Several important bugs have been fixed in this release:
- Resolved a GCC-specific issue with list initialization of const references
- Fixed SFINAE implementation in
gsl::owner
- Improved include directive handling to prevent conflicts with standard library headers
- Updated include paths to comply with C++ Core Guidelines
Try It Out
To start using GSL v4.2.0, you can either:
- Install via vcpkg:
vcpkg install ms-gsl
- Download from GitHub: microsoft/GSL
For detailed release notes and migration guidance, please visit our GitHub repository.
Contributing to GSL
This release would not have been possible without our community contributors. Special thanks to the following individuals for their valuable contributions:
- @ajtruckle
- @apenn-msft
- @asartori86
- @beinhaerter
- @daltairwalter
- @DanielJump
- @HenryHu
- @lord-pando
- @mhthies
- @paparodeo
- @tiagomacarios
If you wish to contribute to GSL, please refer to our open issues and pull requests in the Microsoft/GSL repository on GitHub. We welcome your feedback and contributions!
Please remember to follow our Code of Conduct when contributing to GSL.
Feedback
In addition to contributing, we would love to hear your thoughts on the latest updates to GSL! Please share your feedback and suggestions in the comments below.
0 comments
Be the first to start the discussion.