* infra: individual test executables
We used have tests contained in a single executable. This was fine for
testing, but it would be more convient to separate tests into indivudal
modules so targeted changes could have targeted tests.
This change associates each test file with its own executable. We now
have 14 tests for GSL each of which testing a different component.
* revert -Wno-reserved-identifier
* Update tests/span_tests.cpp
thanks copilot
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
* be sure to include build type in ctest command
* [VS] make sure we are building the correct configuration
* restore tests/span_tests.cpp
* fix build break after merge conflicts
* fix build break after merge conflicts #2
* another try at fixing a build break
* fix silly typo. build break pt 4
* Use file globbing for test sources instead of manual list (#1227)
* Initial plan
* Use file globbing for test sources instead of manual list
Replace the manually maintained list of test sources with file(GLOB) to
automatically discover all .cpp files in the tests directory, excluding
no_exception_ensure_tests.cpp which needs special compilation flags.
This approach:
- Automatically picks up new test files without CMake updates
- Still correctly excludes no_exception_ensure_tests.cpp
- Maintains the same test build configuration
- Works with both C++14 and C++20
Co-authored-by: carsonRadtke <10507970+carsonRadtke@users.noreply.github.com>
---------
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: carsonRadtke <10507970+carsonRadtke@users.noreply.github.com>
---------
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com>
* use cmake presets instead of cmake settings
This change uses a cmake presets file in an effort allow for agentic AI
to better switch between project settings. It replaces the old
CMakeSettings.json for the more flexible CMakePresets.json.
* Update GitHub Actions workflows to use CMake presets (#1223)
* Initial plan
* Update GitHub Actions to use CMake presets for compilers workflow
Co-authored-by: carsonRadtke <10507970+carsonRadtke@users.noreply.github.com>
---------
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: carsonRadtke <10507970+carsonRadtke@users.noreply.github.com>
* remove unused cmake options
* address PR feedback from copilot
* fix build break
---------
Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com>
A new Visual Studio version will soon be available that deprecates the
old syntax for gsl::suppress. Customers will now get a C4875 diagnostic
on suppressions that look like `gsl::suppress(x)` urging them to use
`gsl::suppress("x")` instead.
This change updates the `GSL_SUPPRESS` macro to preprocess
GSL_SUPPRESS(x) to gsl::suppress("x") on clang and new versions of MSVC.
* fix: update conditional static assertion
There is a static assertion that spuriously fails on MSVC that was
version checked. Unfortunately it fires every time there is a new
compiler update, so for now we will remove the version check and add it
back once the compiler bug is fixed.
* fix: ios pipeline failure
Looks like somewhere along the line, the iOS simulator changed the range
of support iOS versions. This changes bumps the version from 9 to 12.0.
Also noticed that the GSL OSX bundle version was quite out of date. I
bumped this from 3.1.0 to 4.2.0 and created an upgrade checklist file in
docs/ so we don't forget these types of tasks in the future.
* bump xcode version from 15.4 to 16.4
* fix compiler warning when building gtest for ios
* allow for missing include dirs on command line
* replace windows-2019 with windows-2025
* update visual studio versions after runner bump
* PR feedback: make sure markdown links are syntactically correct
- A macro with the very generic name `BYTE_TYPE` is likely to collide with existing code, so get rid of the macro.
- The new solution is to provide a non-deprecated `byte` in the namespace `gsl::impl`.
- Users of GSL should use `gsl::byte`, which is still deprecated when mapped to a `std::std::byte`.
- GSL types and functions need to use `gsl::impl::byte` so they do not trigger the deprecation warning.
- The `gsl::impl::byte` return type in an exported function is not nice, it might mislead users to use that type in their own declarations. But the `BYTE_TYPE` solution is not better in this respect.
Co-authored-by: Werner Henze <w.henze@avm.de>
- reintroduce documentation internal links
- remove `gsl::` prefix in table so it is the same as in the other tables
- fix documentation for span::element_type
Co-authored-by: Werner Henze <w.henze@avm.de>
* deprecated features adopted into C++
1) Mark the following GSL features as deprecated:
- gsl::unique_ptr (always)
- gsl::shared_ptr (always)
- gsl::byte (since c++17)
- gsl::joining_thread (never implemented)
2) Refactor existing deprecations to use the new GSL_DEPRECATED(msg) macro.
3) Create a section in the README for deprecated features in the
standard.
* do not deprecate gsl::to_integer because we never claim to implement it.
* do not use gsl::byte if it is deprecated
Reverts commit that changes #include "assert" -> #include "gsl/assert".
This change is necessary in order to comply with CppCoreGuideline's
SF.12. Now we do #include "./assert".
* Add more gsl::span tests [copilot]
This PR adds comprehensive unit tests for `gsl::span` to ensure its correctness and consistency. The following tests have been added:
1. **Empty Span Tests**:
- Tests to verify the behavior of an empty `gsl::span` and `gsl::span<const int>`.
2. **Conversion Tests**:
- Tests to check the conversion between different types of `gsl::span`.
3. **Comparison Operator Tests**:
- Tests to verify the comparison operators for `gsl::span`.
4. **Deduction Guide Tests**:
- Tests to compare the behavior of `gsl::span` and `std::span` deduction guides for various types of arrays and containers.
These tests help ensure that `gsl::span` behaves correctly in various scenarios and is consistent with `std::span`.
This PR was created with the help of GitHub Copilot.
**Changes**:
- Added tests for empty span.
- Added tests for conversions.
- Added tests for comparison operators.
- Added tests for deduction guides.
**Testing**:
- All new tests have been added to the existing test suite.
- Run the test suite using `ctest` to ensure all tests pass.This PR adds comprehensive unit tests for `gsl::span` to ensure its correctness and consistency. The following tests have been added:
1. **Empty Span Tests**:
- Tests to verify the behavior of an empty `gsl::span` and `gsl::span<const int>`.
2. **Conversion Tests**:
- Tests to check the conversion between different types of `gsl::span`.
3. **Comparison Operator Tests**:
- Tests to verify the comparison operators for `gsl::span`.
4. **Deduction Guide Tests**:
- Tests to compare the behavior of `gsl::span` and `std::span` deduction guides for various types of arrays and containers.
These tests help ensure that `gsl::span` behaves correctly in various scenarios and is consistent with `std::span`.
This PR was created with the help of GitHub Copilot.
**Changes**:
- Added tests for empty span.
- Added tests for conversions.
- Added tests for comparison operators.
- Added tests for deduction guides.
**Testing**:
- All new tests have been added to the existing test suite.
- Run the test suite using `ctest` to ensure all tests pass.
* fix tests for pre-C++17
Office is seeing build breaks due to `#include "span"` including
C++20 span instead of gsl/span. Most likely we want all headers
includes qualified with "gsl/" to avoid similar issues.
- `strict_not_null<std::unique_ptr<int>>{ std::make_unique<int>()}` failed to compile
- `strict_not_null` ctor needs to move the passed `unique_ptr`, not copy
- Copied `not_null` `TestNotNullConstructors` for `strict_not_null`
- The `noexcept` specifiers on the `strict_not_null` and `not_null` constructors were out of sync.
- Added unit test for `not_null<unique_ptr<T>>` and for `strict_not_null<unique_ptr<T>>`
- Added unit test for `gsl::swap` for two `strict_not_null`
- Added unit test for `gsl::swap` for `not_null` and `strict_not_null`
Co-authored-by: Werner Henze <w.henze@avm.de>
When setting `GSL_USE_STD_BYTE` to zero, then the unit test does not compile because `byte` is ambiguous (could be `std::byte` or `gsl::byte`). So `gsl::` prefix is needed for `byte`.
It looks like the unit tests never ran on a platform where `gsl::byte` is not based on `std::byte`.
It does not make much sense to test `std::byte` for compliance, so make the unit tests based on the GSL implementation of `gsl::byte` (`#define GSL_USE_STD_BYTE 0`).
Co-authored-by: Werner Henze <werner.henze+gitcommits@posteo.de>
`std::enable_if_t` must not be used as a default template argument, otherwise the instantiator will be able to override it freely with something that doesn't fail substitution. Instead, `std::enable_if_t` itself must be the type of the template argument.
More information in the examples here: https://en.cppreference.com/w/cpp/types/enable_if
* fix failing pipeline tests
* upgrade to googletest v1.14.0 so it works with newer cmake versions
* fix android pipeline to permit new cmake versions (short-term fix)
* improve performance of span_iterator w/ clang
Issue: #1165
Before this PR, the range-for loop was ~3300x slower. After this PR, it
is ~1.005x slower
The clang optimizer is very good at optimizing `current != end`, so
we changed to this idiom. This moves the Expects assertion into the
constructor instead of on the hot-path which is called whenever either
operator++ or operator* is called.
Note: The codegen for the assertion is still a missed optimization,
but less worrisome as it only happens once per iterator.
Note: benchmarks on M1 Macbook Pro w/ Apple Clang 16.0.0
* Remove unused headers from gsl/pointers
forward is already declared in utility, no need to include algorithm which is relativaly heavy
hash is already declared in memory, no need to bring brand-new header system_error for hash only
* Fix: add missing header <functional> to gsl/pointers due to using less/greater
move pipeline testing from AzDO to GitHub Actions.
* update clang versions to 13-15
* update gcc versions to 10-12
* update xcode versions to 14.3.1 and 15.4
* test against C++23 (where supported)
Job has been failing for months and is preventing other PRs from getting
merged. This PR fixes the pipeline - it changed the following:
- runs on macos-latest-large (which is a non-arm image)
- starts the emulator under java8 (see
https://learn.microsoft.com/en-us/java/openjdk/transition-from-java-8-to-java-11)
- runs emulator with -no-audio
The above were requirements to get the pipeline running. Other changes
include the following:
- The job will auto-cancel when a newer commit is pushed to the
PR.
- The 'Wait for emulator ready' step now has a 2 minute timeout. This
is necessary because we get no indication on whether or not the
command that started the emulator suceeded. I believe there is room
for improvement here, but it is outside the scope of the PR.
Two warnings were being emitted in the MSVC+LLVM tests.
The warning `-Wunsafe-buffer-usage` is initially introduced in some capacity here https://reviews.llvm.org/D137346 pointing to documentation at https://discourse.llvm.org/t/rfc-c-buffer-hardening/65734. The warning is a stylistic checker whose goal is to "emit a warning every time an unsafe operation is performed on a raw pointer". This type of programming model is not useful for library implementations of types such as `span`, where direct manipulation of raw pointers is inevitable, so disable the warning altogether.
There is also a false-positive warning https://github.com/llvm/llvm-project/issues/65689 that I've disabled inline.
- Add anchor for `finally` in `headers.md` so that the link in `README.md` can work
- In `README.md` add code formatting for the character types of the `zstring` and `string_span` types
- In `README.md` change code formatting to links for GSL types
- Vertical alignment