{"id":13418994,"url":"https://github.com/gsl-lite/gsl-lite","last_synced_at":"2026-03-14T14:26:41.985Z","repository":{"id":39102442,"uuid":"43079276","full_name":"gsl-lite/gsl-lite","owner":"gsl-lite","description":"ISO C++ Core Guidelines Library implementation for C++98, C++11 up","archived":false,"fork":false,"pushed_at":"2025-05-13T23:11:17.000Z","size":1656,"stargazers_count":927,"open_issues_count":18,"forks_count":108,"subscribers_count":45,"default_branch":"master","last_synced_at":"2025-05-14T18:02:36.925Z","etag":null,"topics":["cpp11","cpp14","cpp17","cpp98","gsl","gsl-implementations","header-only","no-dependencies","single-file"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gsl-lite.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGES.txt","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2015-09-24T16:34:57.000Z","updated_at":"2025-05-13T17:39:15.000Z","dependencies_parsed_at":"2022-09-21T09:11:22.666Z","dependency_job_id":"e02402d3-b045-41db-8bbc-a41805c80767","html_url":"https://github.com/gsl-lite/gsl-lite","commit_stats":{"total_commits":868,"total_committers":38,"mean_commits":"22.842105263157894","dds":"0.23502304147465436","last_synced_commit":"bd9eb162d42d8ae6a7e86902ca7060247d71ac41"},"previous_names":["martinmoene/gsl-lite"],"tags_count":60,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gsl-lite%2Fgsl-lite","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gsl-lite%2Fgsl-lite/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gsl-lite%2Fgsl-lite/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gsl-lite%2Fgsl-lite/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gsl-lite","download_url":"https://codeload.github.com/gsl-lite/gsl-lite/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254198452,"owners_count":22030964,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cpp11","cpp14","cpp17","cpp98","gsl","gsl-implementations","header-only","no-dependencies","single-file"],"created_at":"2024-07-30T22:01:09.875Z","updated_at":"2026-03-14T14:26:41.973Z","avatar_url":"https://github.com/gsl-lite.png","language":"C++","funding_links":[],"categories":["TODO scan for Android support in followings","Standard/Support Libraries"],"sub_categories":[],"readme":"# *gsl-lite*\n\n\n| metadata | build  | packages | try online |\n| -------- | ------ | -------- | ---------- |\n| [![Language](https://badgen.net/badge/C++/98,11+/blue)](https://en.wikipedia.org/wiki/C%2B%2B#Standardization) \u003cbr\u003e [![License](https://badgen.net/github/license/gsl-lite/gsl-lite)](https://opensource.org/license/MIT) \u003cbr\u003e [![Version](https://badgen.net/github/release/gsl-lite/gsl-lite)](https://github.com/gsl-lite/gsl-lite/releases)   |   [![Azure Pipelines build status](https://dev.azure.com/gsl-lite/gsl-lite/_apis/build/status/gsl-lite.gsl-lite?branchName=master)](https://dev.azure.com/gsl-lite/gsl-lite/_build/latest?definitionId=1\u0026branchName=master) \u003cbr\u003e [![AppVeyor build status](https://ci.appveyor.com/api/projects/status/1v6eqy68m8g7tm06?svg=true)](https://ci.appveyor.com/project/gsl-lite/gsl-lite)   |   [![Vcpkg](https://badgen.net/badge/latest/on%20Vcpkg/blue)](https://vcpkg.io/en/package/gsl-lite) \u003cbr\u003e [![Conan](https://badgen.net/badge/latest/on%20Conan/blue)](https://conan.io/center/recipes/gsl-lite) \u003cbr\u003e [![single header](https://badgen.net/badge/latest/single%20header/blue)](https://raw.githubusercontent.com/gsl-lite/gsl-lite/master/include/gsl-lite/gsl-lite.hpp)   |   [![Try it on Compiler Explorer](https://badgen.net/badge/on/Compiler%20Explorer/blue)](https://gcc.godbolt.org/z/8jqq6P1G5) \u003cbr\u003e [![Try it on Wandbox](https://badgen.net/badge/on/Wandbox/blue)](https://wandbox.org/permlink/JADF95qldnpt0i0v)   |\n\n\n***gsl-lite*** is a portable, single-file, header-only library for defensive programming based on the [C++ Core Guidelines Support Library](https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#S-gsl) specification.\n\n\n## Contents\n\n- [Example usage](#example-usage)\n- [In a nutshell](#in-a-nutshell)\n- [License](#license)\n- [Dependencies](#dependencies)\n- [Installation and use](#installation-and-use)\n- [Why *gsl-lite*?](#why-gsl-lite)\n- [Features](#features)\n- [Reference documentation](doc/Reference.md)\n- [Migration guide](#migration-guide)\n- [Using *gsl-lite* in libraries](#using-gsl-lite-in-libraries)\n- [Reported to work with](#reported-to-work-with)\n- [Version semantics](#version-semantics)\n- [Contributing](#contributing)\n\n\n## Example usage\n\n```c++\n#include \u003cmemory\u003e\n#include \u003cutility\u003e\n#include \u003cnumeric\u003e\n\n#include \u003cgsl-lite/gsl-lite.hpp\u003e\n\n\nnamespace my_lib {\n\n    // Define this in your own namespace.\n    namespace gsl = ::gsl_lite;\n\n    // `span\u003cT[, Extent]\u003e`: contiguous range with bounds checks\n    double mean( gsl::span\u003cdouble const\u003e values )\n    {\n        // `gsl_Expects( cond )`: precondition check\n        gsl_Expects( !values.empty() );\n    \n        double sum = std::accumulate( values.begin(), values.end(), 0. );\n\n        // `narrow_failfast\u003cT\u003e( u )`: checked numeric cast\n        double num = gsl::narrow_failfast\u003cdouble\u003e( std::ssize( values ) );\n\n        return sum / num;\n    }\n\n    class Resource\n    {\n        ...\n    public:\n        Resource( std::size_t size );\n    };\n\n    // Type-encoded precondition with `not_null\u003cP\u003e`\n    void consumeResource( gsl::not_null\u003cstd::unique_ptr\u003cResource\u003e\u003e resource );\n\n    // Type-encoded postcondition with `not_null\u003cP\u003e`\n    gsl::not_null\u003cstd::unique_ptr\u003cResource\u003e\u003e acquireResource( std::size_t size )\n    {\n        // A flavor of `make_unique\u003cT\u003e()` which returns `not_null\u003cstd::unique_ptr\u003cT\u003e\u003e`\n        return gsl::make_unique\u003cResource\u003e( size );\n    }\n\n} // namespace my_lib\n```\n\n\n## In a nutshell\n\n*gsl-lite* strives to implement the [Guidelines Support Library specification](https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#S-gsl) of the C++ Core Guidelines\nmaintained by the [Standard C++ Foundation](https://isocpp.org/).\nThe library is originally based on [Microsoft GSL](https://github.com/microsoft/gsl) and was adapted for C++98, C++03. It also works when compiled as C++11, C++14, C++17, C++20, or C++23.\n\n*gsl-lite* does not interfere with Microsoft GSL since both libraries live in different namespaces (`gsl_lite` vs. `gsl`).\n\n*gsl-lite* recognizes when it is compiled for the CUDA platform and decorates some functions with `__host__` and `__device__` accordingly.\n\n\n## License\n\n*gsl-lite* uses the [MIT](LICENSE) license.\n\n\n## Dependencies\n\n*gsl-lite* has no dependencies other than the [C++ standard library](http://en.cppreference.com/w/cpp/header).\n\n\n## Installation and use\n\nThe recommended way to consume *gsl-lite* in your CMake project is to use `find_package()` to locate the package `gsl-lite`\nand `target_link_libraries()` to link to the imported target `gsl-lite::gsl-lite`:\n\n```cmake\ncmake_minimum_required( VERSION 3.20 FATAL_ERROR )\n\nproject( my-program LANGUAGES CXX )\n\nfind_package( gsl-lite 1.1 REQUIRED )\n\nadd_executable( my-program main.cpp )\ntarget_compile_features( my-program PRIVATE cxx_std_17 )\ntarget_link_libraries( my-program PRIVATE gsl-lite::gsl-lite )\n```\n\n*gsl-lite* is available via [Vcpkg](https://vcpkg.io/en/package/gsl-lite), [Conan](https://conan.io/center/recipes/gsl-lite),\nand possibly other package managers. It may also be obtained with [CPM](https://github.com/cpm-cmake/CPM.cmake):\n```cmake\nCPMFindPackage( NAME gsl-lite VERSION 1.1.0 GITHUB_REPOSITORY gsl-lite/gsl-lite )\n```\nSee the directories [example/with-CPM](https://github.com/gsl-lite/gsl-lite/tree/master/example/with-CPM) and\n[example/with-Vcpkg](https://github.com/gsl-lite/gsl-lite/tree/master/example/with-Vcpkg) for example projects\nthat use CPM and Vcpkg, respectively, to obtain *gsl-lite*.\n\nOnce the build system is set up, include the `\u003cgsl-lite/gsl-lite.hpp\u003e` header file to use *gsl-lite*:\n\n```c++\n// main.cpp\n\n#include \u003ciostream\u003e\n\n#include \u003cgsl-lite/gsl-lite.hpp\u003e\n\nvoid printCmdArgs( gsl_lite::span\u003cgsl_lite::zstring const\u003e cmdArgs )\n{\n    gsl_Expects( !cmdArgs.empty() );\n\n    auto argsWithoutExeName = cmdArgs.subspan( 1 );\n    for ( auto arg : argsWithoutExeName )\n    {\n        std::cout \u003c\u003c arg \u003c\u003c \"\\n\";\n    }\n}\n\nint main( int argc, char* argv[] )\n{\n    auto numArgs = gsl_lite::narrow_failfast\u003cstd::size_t\u003e( argc );\n    auto cmdArgs = gsl_lite::span( argv, numArgs );\n    printCmdArgs( cmdArgs );\n}\n```\n\n\n## Why *gsl-lite*?\n\n*gsl-lite* is different from [Microsoft GSL](https://github.com/microsoft/gsl), the default implementation of the\n[C++ Core Guidelines support library (GSL)](https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines), in the following ways:\n\n- *gsl-lite* maintains support for older versions of C++ (C++98, C++03, C++11) and older compilers.  \n  (see: [Reported to work with](#reported-to-work-with))\n- *gsl-lite* supports [CUDA](https://developer.nvidia.com/cuda-toolkit), and many of its features can be used in CUDA kernel code.\n- [Contract and assertion checks](doc/Reference.md#contract-and-assertion-checks) are more versatile and fine-grained, and\n  runtime enforcement is [configurable](doc/Reference.md#contract-checking-configuration-macros).\n- In *gsl-lite*, `not_null\u003cP\u003e` retains the copyability and movability of `P` and therefore may have a [*moved-from state*](doc/Reference.md#nullability-and-the-moved-from-state),\n  which Microsoft GSL [expressly disallows](https://github.com/microsoft/GSL/issues/1022#issuecomment-1022713632).\n  As a consequence, `not_null\u003cstd::unique_ptr\u003cT\u003e\u003e` is movable in *gsl-lite* but not in Microsoft GSL.\n- *gsl-lite* defines [feature testing macros](doc/Reference.md#feature-checking-macros) and [polyfills](doc/Reference.md#polyfills) useful for targeting multiple versions of C++.\n- *gsl-lite* comes as a single-header library.\n\n\n## Features\n\nSee the [reference documentation](doc/Reference.md) for a detailed explanation of the features provided by *gsl-lite*, and\nSection\u0026nbsp;[GSL: Guidelines support library](https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#S-gsl) of the C++ Core Guidelines\nfor the specification of the Guidelines support library.\n\n\nFeature \\\\ library | GSL spec | MS GSL | *gsl\u0026#8209;lite* | Notes |\n------------------------------------------------------------------------|:-----------:|:-------------:|:-------------------:|:-------|\n[**Views:**](https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#gslview-views) | \u0026nbsp;  | \u0026nbsp;  | \u0026nbsp;       | \u0026nbsp; |\n[`owner\u003c\u003e`](doc/Reference.md#ownerp-c11-and-higher)                      | ✓          | ✓             | ✓¹¹                | Annotate a raw pointer that carries ownership |\n[`not_null\u003c\u003e`](doc/Reference.md#not_nullp)                               | ✓          | ✓             | ✓                  | Annotate a (smart) pointer that must not be `nullptr`; enforces non-nullability at runtime\u003cbr\u003e(cf. `strict_not_null\u003c\u003e` in Microsoft GSL) |\n[`not_null_ic\u003c\u003e`](doc/Reference.md#not_null_icp)                         | -           | ✓             | ✓                  | Like `not_null\u003c\u003e` but allows implicit construction from nullable pointers\u003cbr\u003e(cf. `not_null\u003c\u003e` in Microsoft GSL) |\n[`make_unique\u003c\u003e()`](doc/Reference.md#not_nullp)                          | -           | -             | ✓¹¹                | Like [`std::make_unique\u003cT\u003e()`](https://en.cppreference.com/w/cpp/memory/unique_ptr/make_unique) but returns `not_null\u003cstd::unique_ptr\u003cT\u003e\u003e` |\n[`make_shared\u003c\u003e()`](doc/Reference.md#not_nullp)                          | -           | -             | ✓¹¹                | Like [`std::make_shared\u003cT\u003e()`](https://en.cppreference.com/w/cpp/memory/shared_ptr/make_shared) but returns `not_null\u003cstd::shared_ptr\u003cT\u003e\u003e` |\n[`span\u003c\u003e`](doc/Reference.md#safe-contiguous-ranges)                      | ✓          | ✓             | ✓                  | Like [`std::span\u003c\u003e`](https://en.cppreference.com/w/cpp/container/span) but with bounds-checking |\n[`zstring`\u003cbr\u003e`czstring`](doc/Reference.md#string-type-aliases)          | ✓          | ✓             | ✓                  | Aliases for `char *` and `char const *` to be used for 0-terminated strings (C-style strings) |\n[`wzstring`\u003cbr\u003e`cwzstring`](doc/Reference.md#string-type-aliases)        | -           | ✓             | ✓                  | Aliases for `wchar_t *` and `wchar_t const *` to be used for 0-terminated strings (C-style strings) |\n[`u8zstring`\u003cbr\u003e`cu8zstring`](doc/Reference.md#string-type-aliases)      | -           | ✓             | ✓²⁰                | Aliases for `char8_t *` and `char8_t const *` to be used for 0-terminated UTF-8 strings |\n[`u16zstring`\u003cbr\u003e`cu16zstring`](doc/Reference.md#string-type-aliases)    | -           | ✓             | ✓¹¹                | Aliases for `char16_t *` and `char16_t const *` to be used for 0-terminated UTF-16 strings |\n[`u32zstring`\u003cbr\u003e`cu32zstring`](doc/Reference.md#string-type-aliases)    | -           | ✓             | ✓¹¹                | Aliases for `char32_t *` and `char32_t const *` to be used for 0-terminated UTF-32 strings |\n[**Assertions:**](https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#gslassert-assertions) | \u0026nbsp; | \u0026nbsp; | \u0026nbsp; | \u0026nbsp;|\n[`Expects()`](doc/Reference.md#contract-and-assertion-checks)            | ✓          | ✓             | (✓)                 | Checks precondition\u003cbr\u003e(only defined in [GSL compatibility mode](doc/Reference.md#gsl_feature_gsl_compatibility_mode0)) |\n[`Ensures()`](doc/Reference.md#contract-and-assertion-checks)            | ✓          | ✓             | (✓)                 | Checks precondition\u003cbr\u003e(only defined in [GSL compatibility mode](doc/Reference.md#gsl_feature_gsl_compatibility_mode0)) |\n[`gsl_Expects()`](doc/Reference.md#contract-and-assertion-checks)        | -           | -             | ✓                   | Checks precondition |\n[`gsl_ExpectsDebug()`](doc/Reference.md#contract-and-assertion-checks)   | -           | -             | ✓                   | Checks precondition unless [`NDEBUG`](https://en.cppreference.com/w/cpp/error/assert) is defined |\n[`gsl_ExpectsAudit()`](doc/Reference.md#contract-and-assertion-checks)   | -           | -             | ✓                   | Checks precondition if [audit mode](doc/Reference.md#runtime-enforcement) is enabled |\n[`gsl_Ensures()`](doc/Reference.md#contract-and-assertion-checks)        | -           | -             | ✓                   | Checks postcondition |\n[`gsl_EnsuresDebug()`](doc/Reference.md#contract-and-assertion-checks)   | -           | -             | ✓                   | Checks postcondition unless [`NDEBUG`](https://en.cppreference.com/w/cpp/error/assert) is defined |\n[`gsl_EnsuresAudit()`](doc/Reference.md#contract-and-assertion-checks)   | -           | -             | ✓                   | Checks postcondition if [audit mode](doc/Reference.md#runtime-enforcement) is enabled |\n[`gsl_Assert()`\u003cbr\u003e`gsl_AssertAt()`](doc/Reference.md#contract-and-assertion-checks) | - | -           | ✓\u003cbr\u003e✓²⁰           | Checks invariant (statement) |\n[`gsl_Verify()`\u003cbr\u003e`gsl_VerifyAt()`](doc/Reference.md#contract-and-assertion-checks) | - | -           | ✓\u003cbr\u003e✓²⁰           | Checks invariant (expression) |\n[`gsl_AssertDebug()`\u003cbr\u003e`gsl_AssertAtDebug()`](doc/Reference.md#contract-and-assertion-checks) | - | - | ✓\u003cbr\u003e✓²⁰           | Checks invariant unless [`NDEBUG`](https://en.cppreference.com/w/cpp/error/assert) is defined |\n[`gsl_AssertAudit()`\u003cbr\u003e`gsl_AssertAtAudit()`](doc/Reference.md#contract-and-assertion-checks) | - | - | ✓\u003cbr\u003e✓²⁰           | Checks invariant if [audit mode](doc/Reference.md#runtime-enforcement) is enabled |\n[`gsl_FailFast()`\u003cbr\u003e`gsl_FailFastAt()`](doc/Reference.md#contract-and-assertion-checks) | - | -       | ✓\u003cbr\u003e✓²⁰           | Terminates execution |\n[**Utilities:**](https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#gslutil-utilities) | \u0026nbsp;  | \u0026nbsp; | \u0026nbsp; | \u0026nbsp; |\n[`finally()`](doc/Reference.md#ad-hoc-resource-management-c11-and-higher) | ✓         | ✓             | ✓¹¹                | Returns an object that executes a given action in its destructor; use for ad hoc resource cleanup |\n[`on_return()`](doc/Reference.md#ad-hoc-resource-management-c11-and-higher) | -        | -             | (✓¹¹)               | Creates an object that executes a given action in its destructor if no exception occurred\u003cbr\u003e([opt-in](doc/Reference.md#gsl_feature_experimental_return_guard0) feature) |\n[`on_error()`](doc/Reference.md#ad-hoc-resource-management-c11-and-higher) | -         | -             | (✓¹¹)               | Creates an object that executes a given action in its destructor if an exception was thrown\u003cbr\u003e([opt-in](doc/Reference.md#gsl_feature_experimental_return_guard0) feature) |\n[`at()`](doc/Reference.md#bounds-checked-element-access)                 | ✓          | ✓             | ✓                 | Bounds-checked element access for C-style arrays and containers with random access |\n[`index`](doc/Reference.md#integer-type-aliases)                         | ✓          | ✓             | ✓                 | Signed integer type for indexes and subscripts |\n[`dim`](doc/Reference.md#integer-type-aliases)                           | -           | -             | ✓                 | Signed integer type for sizes |\n[`stride`](doc/Reference.md#integer-type-aliases)                        | -           | -             | ✓                 | Signed integer type for index strides |\n[`diff`](doc/Reference.md#integer-type-aliases)                          | -           | -             | ✓                 | Signed integer type for index differences |\n[`narrow_cast\u003c\u003e()`](doc/Reference.md#narrow_castt-u-)                    | ✓          | ✓             | ✓                 | Narrowing cast which tolerates lossy conversions; equivalent to `static_cast\u003c\u003e()` |\n[`narrow\u003c\u003e()`](doc/Reference.md#narrowt-u-)                              | ✓          | ✓             | ✓                 | Checked narrowing cast; throws `narrowing_error` if cast is lossy |\n[`narrow_failfast\u003c\u003e()`](doc/Reference.md#narrow_failfastt-u-)            | -           | -             | ✓                 | Checked narrowing cast; fails assertion check if cast is lossy |\n\n¹¹: C++11 or newer required  \n²⁰: C++20 or newer required\n\n\n## Migration guide\n\nStarting with v1.0, *gsl-lite* lives in the single header file `\u003cgsl-lite/gsl-lite.hpp\u003e`, and all its symbols reside in namespace\n`gsl_lite`. By default, *gsl-lite* no longer defines a namespace `gsl` or the unprefixed `Expects()` and `Ensures()` macros for\nprecondition and postcondition checking.\n\nThis change enables coexistence with [Microsoft GSL](https://github.com/microsoft/GSL) ([#194](https://github.com/gsl-lite/gsl-lite/issues/194)).\n\n### Adapting your code\n\nIf you are migrating from *gsl-lite* v0.\\*, adapt your code by referencing namespace `gsl_lite` rather than namespace `gsl`, and by\nusing the prefixed macros `gsl_Expects()` and `gsl_Ensures()` rather than the unprefixed macros `Expects()` and `Ensures()` for\nprecondition and postcondition checking.\n\nNote that *gsl-lite* v1 also changed the defaults for many of *gsl-lite*'s configuration options. See the\n[v1.0.0 release notes](https://github.com/gsl-lite/gsl-lite/releases/tag/v1.0.0) for a comprehensive list of changes.\nThis should not affect you if you had already opted in to version-1 defaults by setting `gsl_CONFIG_DEFAULTS_VERSION=1`\nor by linking to the `gsl::gsl-lite-v1` target in CMake.\n\nTo reduce the pervasiveness of required changes, it can be useful to define a namespace alias inside your own namespace:\n\n```c++\n// my-lib.hpp\n\n#include \u003cgsl-lite/gsl-lite.hpp\u003e  // instead of \u003cgsl/gsl-lite.hpp\u003e\n\nnamespace my_lib {\n\n    namespace gsl = ::gsl_lite;  // convenience alias\n\n    inline double median( gsl::span\u003cdouble const\u003e elements )\n    {\n        gsl_Expects( !elements.empty() );  // instead of Expects()\n        ...\n    }\n\n} // namespace my_lib\n```\n\n### Using the GSL compatibility mode\n\nTo minimize the impact of the breaking changes, *gsl-lite* introduces an optional *GSL compatibility mode* controlled by the\nnew configuration switch [`gsl_FEATURE_GSL_COMPATIBILITY_MODE`](doc/Reference.md#feature-selection-macros), which is is disabled\nby default and can be enabled by defining `gsl_FEATURE_GSL_COMPATIBILITY_MODE=1`.\n\nIf the GSL compatibility mode is enabled, *gsl-lite* additionally makes the following global definitions:\n```c++\nnamespace gsl = ::gsl_lite;\n#define Expects( x )  gsl_Expects( x )\n#define Ensures( x )  gsl_Ensures( x )\n```\n\nThe GSL compatibility mode precludes the use of *gsl-lite* and Microsoft GSL in the same translation unit. Therefore, **do not use\nthe GSL compatibility mode when using *gsl-lite* in a public header file of a library.** (See notes on\n[using *gsl-lite* in libraries](#using-gsl-lite-in-libraries) below.)\n\nThe GSL compatibility mode causes no link-time interference between *gsl-lite* and as Microsoft GSL. Both libraries may be used in\nthe same project as long as no translation unit includes both at the same time.\n\nThe legacy header file `\u003cgsl/gsl-lite.hpp\u003e` now forwards to `\u003cgsl-lite/gsl-lite.hpp\u003e` and implicitly enables the GSL compatibility mode.\nWhen the legacy header is included, it emits a warning message that urges to either migrate to header `\u003cgsl-lite/gsl-lite.hpp\u003e`,\nnamespace `gsl_lite` and the prefixed contract checking macros `gsl_Expects()` and `gsl_Ensures()`, or to explicitly request GSL\ncompatibility by defining `gsl_FEATURE_GSL_COMPATIBILITY_MODE=1`.\n\n\n## Using *gsl-lite* in libraries\n\nMany features of *gsl-lite* are very useful for defining library interfaces, for instance spans, contract checks, or `not_null\u003c\u003e`.\n\n*gsl-lite* can coexist with Microsoft GSL. However, the GSL compatibility mode of *gsl-lite* may cause interference with Microsoft GSL.\nAlso, *gsl-lite* is customizable through a large number of configuration options and switches. These configuration macros may affect the API and\nABI of *gsl-lite* in ways that renders it incompatible with other code. How *gsl-lite* is configured should be the prerogative of the consumer,\nnot the author, of a library.\n\nTherefore, when using *gsl-lite* in a library, please mind the following suggestions:\n\n- Do not define, or rely on, any of *gsl-lite*'s configuration options or switches when using *gsl-lite* in a library.\n- In particular, do not enable the GSL compatibility mode.\n- Do not use the legacy header file `\u003cgsl/gsl-lite.hpp\u003e`, which implicitly enables the GSL compatibility mode; use the header `\u003cgsl-lite/gsl-lite.hpp\u003e` instead.\n- Use namespace `gsl_lite` rather than namespace `gsl`; if desired, define a `namespace gsl = ::gsl_lite;` alias in your own namespace.\n- Use the prefixed contract checking macros `gsl_Expects()` and `gsl_Ensures()` rather than the unprefixed macros `Expects()` and `Ensures()`.\n\n\n## Reported to work with\n\nThe table below mentions the compiler versions and platforms *gsl-lite* is reported to work with.\n\nCompiler             | OS              | Platforms | Versions          | CI |\n--------------------:|:----------------|-----------|------------------:|----|\nGCC                  | Linux           | x64       | 4.7 and newer     | [9, 10, 11, 12, 13, 14](https://dev.azure.com/gsl-lite/gsl-lite/_build?definitionId=1) |\nGCC (MinGW)          | Windows         | x86, x64  | 4.8.4 and newer   |    |\nGCC (DJGPP)          | DOSBox, FreeDOS | x86       | 7.2               |    |\nGCC                  | MacOS           | x64       | 6 and newer       | [11, 12, 13, 14](https://dev.azure.com/gsl-lite/gsl-lite/_build?definitionId=1) |\nClang                | Linux           | x64       | 3.5 and newer     | [11, 12, 13, 14, 15, 16, 17, 18, 19, 20](https://dev.azure.com/gsl-lite/gsl-lite/_build?definitionId=1) |\nClang with libstdc++ | Linux           | x64       | 11 and newer      | [20](https://dev.azure.com/gsl-lite/gsl-lite/_build?definitionId=1) |\nClang                | Windows         | x64       | version shipped with VS | VS [2022, 2026](https://dev.azure.com/gsl-lite/gsl-lite/_build?definitionId=1) |\nMSVC (Visual Studio) | Windows         | x86, x64  | VS 2010 and newer | VS [2010, 2012, 2013, 2015, 2017, 2019](https://ci.appveyor.com/project/gsl-lite/gsl-lite), [2022, 2026](https://dev.azure.com/gsl-lite/gsl-lite/_build?definitionId=1) |\nAppleClang (Xcode)   | MacOS           | x64       | 7.3 and newer     | [15, 16, 17](https://dev.azure.com/gsl-lite/gsl-lite/_build?definitionId=1) |\nNVCC (CUDA Toolkit)  | Linux, Windows  | x64       | 10.2 and newer    | [12.8, 12.9](https://dev.azure.com/gsl-lite/gsl-lite/_build?definitionId=1) |\nARMCC                |                 | ARM       | 5 and newer       | |\n\n\n## Version semantics\n\n*gsl-lite* follows [Semantic Versioning](https://semver.org/) guidelines. We maintain [API](https://en.wikipedia.org/wiki/Application_programming_interface) and\n[ABI](https://en.wikipedia.org/wiki/Application_binary_interface) compatibility and avoid breaking changes in minor and patch releases.\n\nDevelopment of *gsl-lite* happens in the `master` branch. Versioning semantics apply only to tagged releases: there is no stability guarantee between individual\ncommits in the `master` branch, that is, anything added since the last tagged release may be renamed, removed, or have the semantics changed without further notice.\n\nA minor-version release will be compatible (in both ABI and API) with the previous minor-version release. Thus, once a change is released, it becomes part of the API.\n\nSome of the [configuration options](doc/Reference.md#configuration-options-and-switches) may affect the API and ABI of *gsl-lite*.\n\n\n## Contributing\n\nContributions to *gsl-lite* through [pull requests](https://github.com/gsl-lite/gsl-lite/pulls) or [issues](https://github.com/gsl-lite/gsl-lite/issues) are welcome.\n\n*gsl-lite* comes with a test suite that uses an included, slightly modified copy of the [*lest* test framework](https://github.com/martinmoene/lest).\nTo build *gsl-lite*'s test suite, enable the CMake build option `GSL_LITE_OPT_BUILD_TESTS` when configuring the project.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgsl-lite%2Fgsl-lite","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgsl-lite%2Fgsl-lite","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgsl-lite%2Fgsl-lite/lists"}