gsl/3.1.0+2

[brief]

The Guidelines Support Library (GSL) contains functions and types that are suggested for use by the C++ Core Guidelines maintained by the Standard C++ Foundation.

Build Status Build status

The Guidelines Support Library (GSL) contains functions and types that are suggested for use by the C++ Core Guidelines maintained by the Standard C++ Foundation. This repo contains Microsoft's implementation of GSL.

The library includes types like span<T>, string_span, owner<> and others.

The entire implementation is provided inline in the headers under the gsl directory. The implementation generally assumes a platform that implements C++14 support. There are specific workarounds to support MSVC 2015.

While some types have been broken out into their own headers (e.g. gsl/span), it is simplest to just include gsl/gsl and gain access to the entire library.

NOTE: We encourage contributions that improve or refine any of the types in this library as well as ports to other platforms. Please see CONTRIBUTING.md for more information about contributing.

Project Code of Conduct

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact opencode@microsoft.com with any additional questions or comments.

Usage of Third Party Libraries

This project makes use of the Google Test testing library. Please see the ThirdPartyNotices.txt file for details regarding the licensing of Google Test.

Quick Start

Supported Compilers

The GSL officially supports the current and previous major release of MSVC, GCC, Clang, and XCode's Apple-Clang. See our latest test results for the most up-to-date list of supported configurations.

Compiler Toolset Versions Currently Tested Build Status
XCode 11.4 & 10.3 Status
GCC 9 & 8 Status
Clang 11 & 10 Status
Visual Studio with MSVC VS2017 (15.9) & VS2019 (16.4) Status
Visual Studio with LLVM VS2017 (Clang 9) & VS2019 (Clang 10) Status

Note: For gsl::byte to work correctly with Clang and GCC you might have to use the -fno-strict-aliasing compiler option.


If you successfully port GSL to another platform, we would love to hear from you!

Target CI/CD Status
iOS CI
Android CI

Note: These CI/CD steps are run with each pull request, however failures in them are non-blocking.

Building the tests

To build the tests, you will require the following:

These steps assume the source code of this repository has been cloned into a directory named c:\GSL.

  1. Create a directory to contain the build outputs for a particular architecture (we name it c:\GSL\build-x86 in this example).

     cd GSL
     md build-x86
     cd build-x86
    
  2. Configure CMake to use the compiler of your choice (you can see a list by running cmake --help).

     cmake -G "Visual Studio 14 2015" c:\GSL
    
  3. Build the test suite (in this case, in the Debug configuration, Release is another good choice).

     cmake --build . --config Debug
    
  4. Run the test suite.

     ctest -C Debug
    

All tests should pass - indicating your platform is fully supported and you are ready to use the GSL types!

Building GSL - Using vcpkg

You can download and install GSL using the vcpkg dependency manager:

git clone https://github.com/Microsoft/vcpkg.git
cd vcpkg
./bootstrap-vcpkg.sh
./vcpkg integrate install
vcpkg install ms-gsl

The GSL port in vcpkg is kept up to date by Microsoft team members and community contributors. If the version is out of date, please create an issue or pull request on the vcpkg repository.

Using the libraries

As the types are entirely implemented inline in headers, there are no linking requirements.

You can copy the gsl directory into your source tree so it is available to your compiler, then include the appropriate headers in your program.

Alternatively set your compiler's include path flag to point to the GSL development folder (c:\GSL\include in the example above) or installation folder (after running the install). Eg.

MSVC++

/I c:\GSL\include

GCC/clang

-I$HOME/dev/GSL/include

Include the library using:

#include <gsl/gsl>

Usage in CMake

The library provides a Config file for CMake, once installed it can be found via

find_package(Microsoft.GSL CONFIG)

Which, when successful, will add library target called Microsoft.GSL::GSL which you can use via the usual target_link_libraries mechanism.

Debugging visualization support

For Visual Studio users, the file GSL.natvis in the root directory of the repository can be added to your project if you would like more helpful visualization of GSL types in the Visual Studio debugger than would be offered by default.

version 3.1.0+2
license MIT
repository https://pkg.cppget.org/1/stable
download gsl-3.1.0+2.tar.gz
sha256 25bfad676e9514e1fc0cf4ee624428fc929aa10e7c754ca60358d7cf24359b19
project gsl
url github.com/microsoft/GSL
package-url github.com/build2-packaging/gsl/
package-email lyrahgames@mailbox.org

Requires (1)

c++14

Builds

toolchain public-0.16.0
target x86_64-apple-darwin22.5.0
tgt config macos_13-clang_14.0-static_O3
timestamp 2024-03-28 01:34:23 UTC (01 05:24:22 days ago)
result warning (update) | warning (test-installed) | log | rebuild
toolchain public-0.16.0
target x86_64-apple-darwin22.5.0
tgt config macos_13-clang_14.0-O3
timestamp 2024-03-28 01:33:32 UTC (01 05:25:13 days ago)
result warning (update) | warning (test-installed) | log | rebuild
toolchain public-0.16.0
target x86_64-apple-darwin22.5.0
tgt config macos_13-clang_14.0
timestamp 2024-03-28 01:32:42 UTC (01 05:26:04 days ago)
result warning (update) | warning (test-installed) | log | rebuild
toolchain public-0.16.0
target x86_64-apple-darwin22.5.0
tgt config macos_13-clang_15.0-static_O3
timestamp 2024-03-27 17:21:22 UTC (01 13:37:23 days ago)
result warning (update) | warning (test-installed) | log | rebuild
toolchain public-0.16.0
target x86_64-apple-darwin22.5.0
tgt config macos_13-clang_15.0-O3
timestamp 2024-03-27 17:20:31 UTC (01 13:38:14 days ago)
result warning (update) | warning (test-installed) | log | rebuild
toolchain public-0.16.0
target x86_64-apple-darwin22.5.0
tgt config macos_13-clang_15.0
timestamp 2024-03-27 17:19:39 UTC (01 13:39:06 days ago)
result warning (update) | warning (test-installed) | log | rebuild
toolchain public-0.16.0
target aarch64-linux-gnu
tgt config linux_debian_12-clang_16_libc++-static_O3
timestamp 2024-03-27 05:37:02 UTC (02 01:21:43 days ago)
result warning (update) | warning (test-installed) | log | rebuild
toolchain public-0.16.0
target aarch64-linux-gnu
tgt config linux_debian_12-clang_16_libc++-O3
timestamp 2024-03-27 05:34:01 UTC (02 01:24:45 days ago)
result warning (update) | warning (test-installed) | log | rebuild
toolchain public-0.16.0
target aarch64-linux-gnu
tgt config linux_debian_12-clang_16_libc++
timestamp 2024-03-27 05:33:43 UTC (02 01:25:02 days ago)
result warning (update) | warning (test-installed) | log | rebuild
toolchain public-0.16.0
target x86_64-microsoft-win32-msvc14.3
tgt config windows_10-msvc_17.6-static_O2
timestamp 2024-03-26 23:48:48 UTC (02 07:09:57 days ago)
result success | log | rebuild
toolchain public-0.16.0
target x86_64-microsoft-win32-msvc14.3
tgt config windows_10-msvc_17.6-O2
timestamp 2024-03-26 23:45:48 UTC (02 07:12:58 days ago)
result success | log | rebuild
toolchain public-0.16.0
target x86_64-microsoft-win32-msvc14.3
tgt config windows_10-msvc_17.6
timestamp 2024-03-26 23:45:40 UTC (02 07:13:05 days ago)
result success | log | rebuild
toolchain public-0.16.0
target x86_64-microsoft-win32-msvc14.3
tgt config windows_10-msvc_17.5
timestamp 2024-03-26 21:52:19 UTC (02 09:06:26 days ago)
result success | log | rebuild
toolchain public-0.16.0
target x86_64-w64-mingw32
tgt config windows_10-gcc_12.2_mingw_w64-O2
timestamp 2024-03-26 19:48:39 UTC (02 11:10:06 days ago)
result warning (update) | warning (test-installed) | log | rebuild
toolchain public-0.16.0
target x86_64-w64-mingw32
tgt config windows_10-gcc_12.2_mingw_w64
timestamp 2024-03-26 19:48:12 UTC (02 11:10:33 days ago)
result warning (update) | warning (test-installed) | log | rebuild
toolchain public-0.16.0
target aarch64-linux-gnu
tgt config linux_debian_12-clang_15_libc++
timestamp 2024-03-26 15:19:33 UTC (02 15:39:12 days ago)
result warning (update) | warning (test-installed) | log | rebuild
toolchain public-0.16.0
target aarch64-linux-gnu
tgt config linux_debian_12-clang_15
timestamp 2024-03-26 15:15:54 UTC (02 15:42:52 days ago)
result warning (update) | warning (test-installed) | log | rebuild
toolchain public-0.16.0
target aarch64-linux-gnu
tgt config linux_debian_12-clang_16-O3
timestamp 2024-03-26 15:04:19 UTC (02 15:54:26 days ago)
result error (update) | log | rebuild
toolchain public-0.16.0
target aarch64-linux-gnu
tgt config linux_debian_12-clang_16-static_O3
timestamp 2024-03-26 14:52:38 UTC (02 16:06:07 days ago)
result error (update) | log | rebuild
toolchain public-0.16.0
target aarch64-linux-gnu
tgt config linux_debian_12-clang_16
timestamp 2024-03-26 14:51:48 UTC (02 16:06:57 days ago)
result error (update) | log | rebuild
toolchain public-0.16.0
target aarch64-linux-gnu
tgt config linux_debian_11-gcc_12
timestamp 2024-03-26 14:24:03 UTC (02 16:34:43 days ago)
result warning (update) | warning (test-installed) | log | rebuild
toolchain public-0.16.0
target x86_64-linux-gnu
tgt config linux_debian_12-clang_16.0_libc++-static_O3
timestamp 2024-03-26 13:54:11 UTC (02 17:04:34 days ago)
result warning (update) | warning (test-installed) | log | rebuild
toolchain public-0.16.0
target x86_64-linux-gnu
tgt config linux_debian_12-clang_16.0_libc++
timestamp 2024-03-26 13:50:57 UTC (02 17:07:48 days ago)
result warning (update) | warning (test-installed) | log | rebuild
toolchain public-0.16.0
target x86_64-linux-gnu
tgt config linux_debian_12-clang_16.0_libc++-O3
timestamp 2024-03-26 13:50:20 UTC (02 17:08:25 days ago)
result warning (update) | warning (test-installed) | log | rebuild
toolchain public-0.16.0
target x86_64-microsoft-win32-msvc14.3
tgt config windows_10-clang_16.0_llvm_msvc_17.6-static_O2
timestamp 2024-03-26 13:46:47 UTC (02 17:11:59 days ago)
result warning (update) | warning (test-installed) | log | rebuild
toolchain public-0.16.0
target x86_64-microsoft-win32-msvc14.3
tgt config windows_10-clang_16.0_llvm_msvc_17.6
timestamp 2024-03-26 13:45:58 UTC (02 17:12:47 days ago)
result warning (update) | warning (test-installed) | log | rebuild
toolchain public-0.16.0
target x86_64-microsoft-win32-msvc14.3
tgt config windows_10-clang_16.0_llvm_msvc_17.6-O2
timestamp 2024-03-26 13:44:57 UTC (02 17:13:49 days ago)
result warning (update) | warning (test-installed) | log | rebuild
toolchain public-0.16.0
target x86_64-linux-gnu
tgt config linux_fedora_37-gcc_12.2-bindist
timestamp 2024-03-26 13:43:04 UTC (02 17:15:41 days ago)
result warning (update) | warning (test-installed) | log | rebuild
toolchain public-0.16.0
target x86_64-w64-mingw32
tgt config windows_10-gcc_12.2_mingw_w64-static_O2
timestamp 2024-03-26 13:29:47 UTC (02 17:28:58 days ago)
result warning (update) | warning (test-installed) | log | rebuild
toolchain public-0.16.0
target x86_64-linux-gnu
tgt config linux_debian_12-gcc_12-bindist
timestamp 2024-03-26 13:03:13 UTC (02 17:55:32 days ago)
result warning (update) | warning (test-installed) | log | rebuild
toolchain public-0.16.0
target aarch64-linux-gnu
tgt config linux_debian_12-gcc_13-static_O3
timestamp 2024-03-26 12:20:20 UTC (02 18:38:26 days ago)
result error (update) | log | rebuild
toolchain public-0.16.0
target x86_64-microsoft-win32-msvc14.3
tgt config windows_10-clang_15.0_msvc_msvc_17.6
timestamp 2024-03-26 12:11:37 UTC (02 18:47:09 days ago)
result warning (update) | warning (test-installed) | log | rebuild
toolchain public-0.16.0
target aarch64-linux-gnu
tgt config linux_debian_12-gcc_13-O3
timestamp 2024-03-26 12:09:01 UTC (02 18:49:44 days ago)
result error (update) | log | rebuild
toolchain public-0.16.0
target x86_64-freebsd13.2
tgt config freebsd_13-clang_14.0-static_O3
timestamp 2024-03-26 12:08:27 UTC (02 18:50:19 days ago)
result warning (update) | warning (test-installed) | log | rebuild
toolchain public-0.16.0
target aarch64-linux-gnu
tgt config linux_debian_12-gcc_13-ndebug_O3
timestamp 2024-03-26 12:08:10 UTC (02 18:50:36 days ago)
result error (update) | log | rebuild
toolchain public-0.16.0
target aarch64-linux-gnu
tgt config linux_debian_12-gcc_13
timestamp 2024-03-26 12:05:25 UTC (02 18:53:20 days ago)
result error (update) | log | rebuild
toolchain public-0.16.0
target x86_64-freebsd13.2
tgt config freebsd_13-clang_14.0-O3
timestamp 2024-03-26 12:02:08 UTC (02 18:56:37 days ago)
result warning (update) | warning (test-installed) | log | rebuild
toolchain public-0.16.0
target x86_64-freebsd13.2
tgt config freebsd_13-clang_14.0
timestamp 2024-03-26 11:56:57 UTC (02 19:01:48 days ago)
result warning (update) | warning (test-installed) | log | rebuild
toolchain public-0.16.0
target x86_64-linux-gnu
tgt config linux_debian_12-clang_15.0_libc++
timestamp 2024-03-26 11:48:08 UTC (02 19:10:37 days ago)
result warning (update) | warning (test-installed) | log | rebuild
toolchain public-0.16.0
target x86_64-linux-gnu
tgt config linux_debian_12-clang_15.0
timestamp 2024-03-26 11:44:05 UTC (02 19:14:41 days ago)
result warning (update) | warning (test-installed) | log | rebuild
toolchain public-0.16.0
target x86_64-freebsd12.4
tgt config freebsd_12-clang_13.0
timestamp 2024-03-26 11:35:56 UTC (02 19:22:49 days ago)
result warning (update) | warning (test-installed) | log | rebuild
toolchain public-0.16.0
target x86_64-linux-gnu
tgt config linux_debian_11-gcc_12.1
timestamp 2024-03-26 11:33:15 UTC (02 19:25:30 days ago)
result warning (update) | warning (test-installed) | log | rebuild
toolchain public-0.16.0
target x86_64-apple-darwin22.5.0
tgt config macos_13-gcc_13_homebrew-static_O3
timestamp 2024-03-26 11:08:33 UTC (02 19:50:13 days ago)
result error (update) | log | rebuild
toolchain public-0.16.0
target x86_64-apple-darwin22.5.0
tgt config macos_13-gcc_13_homebrew-O3
timestamp 2024-03-26 11:07:47 UTC (02 19:50:58 days ago)
result error (update) | log | rebuild
toolchain public-0.16.0
target x86_64-apple-darwin22.5.0
tgt config macos_13-gcc_13_homebrew
timestamp 2024-03-26 11:06:58 UTC (02 19:51:47 days ago)
result error (update) | log | rebuild
toolchain public-0.16.0
target x86_64-linux-gnu
tgt config linux_fedora_38-gcc_13-bindist
timestamp 2024-03-26 11:06:23 UTC (02 19:52:23 days ago)
result error (update) | log | rebuild
toolchain public-0.16.0
target x86_64-linux-gnu
tgt config linux_debian_12-clang_16.0-static_O3
timestamp 2024-03-26 11:00:07 UTC (02 19:58:38 days ago)
result error (update) | log | rebuild
toolchain public-0.16.0
target x86_64-linux-gnu
tgt config linux_debian_12-clang_16.0-O3
timestamp 2024-03-26 10:58:41 UTC (02 20:00:04 days ago)
result error (update) | log | rebuild
toolchain public-0.16.0
target x86_64-linux-gnu
tgt config linux_debian_12-clang_16.0
timestamp 2024-03-26 10:58:04 UTC (02 20:00:42 days ago)
result error (update) | log | rebuild
toolchain public-0.16.0
target x86_64-linux-gnu
tgt config linux_debian_12-gcc_13.1
timestamp 2024-03-26 10:38:37 UTC (02 20:20:08 days ago)
result error (update) | log | rebuild
toolchain public-0.16.0
target x86_64-linux-gnu
tgt config linux_debian_12-gcc_13.1-static_O3
timestamp 2024-03-26 10:38:21 UTC (02 20:20:24 days ago)
result error (update) | log | rebuild
toolchain public-0.16.0
target x86_64-linux-gnu
tgt config linux_debian_12-gcc_13.1-ndebug_O3
timestamp 2024-03-26 10:37:36 UTC (02 20:21:10 days ago)
result error (update) | log | rebuild
toolchain public-0.16.0
target x86_64-linux-gnu
tgt config linux_debian_12-gcc_13.1-O3
timestamp 2024-03-26 10:35:45 UTC (02 20:23:01 days ago)
result error (update) | log | rebuild