Commit Graph

1026 Commits

Author SHA1 Message Date
Carson Radtke
2e65f54728 PR feedback: make sure markdown links are syntactically correct 2025-09-30 11:29:30 -06:00
Carson Radtke
db6568b2a4 update visual studio versions after runner bump 2025-09-29 11:52:10 -06:00
Carson Radtke
e91d455efb replace windows-2019 with windows-2025 2025-09-29 11:41:02 -06:00
Carson Radtke
ed516e2272 allow for missing include dirs on command line 2025-09-29 11:30:38 -06:00
Carson Radtke
a0e1ffe13b Merge branch 'carsonradtke/fix-static-assertion' into carsonradtke/fix-github-pipeline 2025-09-29 11:10:12 -06:00
Carson Radtke
5ce7964004 fix compiler warning when building gtest for ios 2025-09-29 11:05:55 -06:00
Carson Radtke
bfdf94670e bump xcode version from 15.4 to 16.4 2025-09-29 10:24:37 -06:00
Carson Radtke
69a46a2248 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.
2025-09-29 10:19:48 -06:00
Carson Radtke
271f6abe70 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.
2025-09-29 09:56:43 -06:00
Copilot
7e0943d20d Add constexpr to not_null comparison operators (#1208)
* Initial plan for issue

* Add test and plan to make not_null comparison functions constexpr

Co-authored-by: carsonRadtke <10507970+carsonRadtke@users.noreply.github.com>

* Add constexpr to not_null comparison operators

Co-authored-by: carsonRadtke <10507970+carsonRadtke@users.noreply.github.com>

* Fix copyright year in constexpr_notnull_tests.cpp

Co-authored-by: carsonRadtke <10507970+carsonRadtke@users.noreply.github.com>

* Fix constexpr tests for better compiler compatibility

Co-authored-by: carsonRadtke <10507970+carsonRadtke@users.noreply.github.com>

* Remove build artifacts and update .gitignore

Co-authored-by: carsonRadtke <10507970+carsonRadtke@users.noreply.github.com>

* Fix constexpr tests to be compatible with more compilers

Co-authored-by: carsonRadtke <10507970+carsonRadtke@users.noreply.github.com>

* copilot: Provide more project context for the Copilot coding agent (#1207)

* copilot: create .github/copilot-instructions.md

This file provides additional context and instructions to GitHub
Copilot so it can better understand the codebase and coding conventions.

More can be found about this file at the following links:
 - [Best practices for using Copilot to work on tasks](https://docs.github.com/en/enterprise-cloud@latest/copilot/using-github-copilot/using-copilot-coding-agent-to-work-on-tasks/best-practices-for-using-copilot-to-work-on-taskshttps://docs.github.com/en/enterprise-cloud@latest/copilot/using-github-copilot/using-copilot-coding-agent-to-work-on-tasks/best-practices-for-using-copilot-to-work-on-tasks)
 - [Adding repository custom instructions for GitHub Copilot](https://docs.github.com/en/enterprise-cloud@latest/copilot/customizing-copilot/adding-repository-custom-instructions-for-github-copilot?tool=webuihttps://docs.github.com/en/enterprise-cloud@latest/copilot/customizing-copilot/adding-repository-custom-instructions-for-github-copilot)

* copilot: add copilot-setup-steps.yml

This new workflow is done when copilot loads into an environment and
enables copilot to be sure it has the proper dependencies before working
on changes. Also included in the change are explicit instructions on
what to do before reporting back "done".

* Initial plan for issue

* Rebase onto main and verify changes meet project guidelines

Co-authored-by: carsonRadtke <10507970+carsonRadtke@users.noreply.github.com>

* Update .gitignore to exclude build-cxx* directories

Co-authored-by: carsonRadtke <10507970+carsonRadtke@users.noreply.github.com>

* Fix newline at end of constexpr_notnull_tests.cpp and update .gitignore

Co-authored-by: carsonRadtke <10507970+carsonRadtke@users.noreply.github.com>

* Remove C++14 feature check that is redundant since C++14 is the minimum supported standard

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: Carson Radtke <carsonradtke@microsoft.com>
2025-05-22 11:52:47 -06:00
Copilot
2d343b0440 Document differences between hardened std::span and gsl::span (#1206)
* Initial plan for issue

* Document differences between hardened std::span and gsl::span

Co-authored-by: carsonRadtke <10507970+carsonRadtke@users.noreply.github.com>

* Simplify documentation for span differences

Co-authored-by: carsonRadtke <10507970+carsonRadtke@users.noreply.github.com>

* Enhance span documentation with comparison table and links

Co-authored-by: carsonRadtke <10507970+carsonRadtke@users.noreply.github.com>

* Fix library hardening documentation links

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>
2025-05-22 11:34:22 -06:00
Carson Radtke
c21970972b copilot: Provide more project context for the Copilot coding agent (#1207)
* copilot: create .github/copilot-instructions.md

This file provides additional context and instructions to GitHub
Copilot so it can better understand the codebase and coding conventions.

More can be found about this file at the following links:
 - [Best practices for using Copilot to work on tasks](https://docs.github.com/en/enterprise-cloud@latest/copilot/using-github-copilot/using-copilot-coding-agent-to-work-on-tasks/best-practices-for-using-copilot-to-work-on-taskshttps://docs.github.com/en/enterprise-cloud@latest/copilot/using-github-copilot/using-copilot-coding-agent-to-work-on-tasks/best-practices-for-using-copilot-to-work-on-tasks)
 - [Adding repository custom instructions for GitHub Copilot](https://docs.github.com/en/enterprise-cloud@latest/copilot/customizing-copilot/adding-repository-custom-instructions-for-github-copilot?tool=webuihttps://docs.github.com/en/enterprise-cloud@latest/copilot/customizing-copilot/adding-repository-custom-instructions-for-github-copilot)

* copilot: add copilot-setup-steps.yml

This new workflow is done when copilot loads into an environment and
enables copilot to be sure it has the proper dependencies before working
on changes. Also included in the change are explicit instructions on
what to do before reporting back "done".
2025-05-22 10:32:01 -06:00
ozaktash
466e4ebaa5 Update return by value threshold in gsl::not_null (#1205)
- Allow returning by value for types that are not greater than two pointers in size
2025-05-12 11:02:03 -06:00
Werner Henze
3325bbd33d Fix version info (#1202)
Just tagging as 4.2.0 is not enough, the version number must be incremented for cmake and in the readme. Compare https://github.com/microsoft/GSL/pull/1163.

Co-authored-by: Werner Henze <w.henze@avm.de>
2025-03-27 11:00:24 -05:00
Werner Henze
2828399820 replace BYTE_TYPE with a solution based on namespaces (#1201)
- 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>
v4.2.0
2025-02-28 08:53:25 -06:00
Werner Henze
c5fbb81ad4 documentation (#1200)
- 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>
2025-02-28 08:49:53 -06:00
Carson Radtke
7fabaa499d deprecate features adopted into C++ (#1198)
* 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
2025-02-14 11:24:51 -06:00
Carson Radtke
4742bc192a use relative path in # include (#1194)
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".
2025-02-12 09:16:45 -06:00
Carson Radtke
ec729d63a7 introduce gsl::not_null<T>::element_type (#1196)
* introduce gsl::not_null<T>::element_type

* use std::is_same instead of is_same_v

* fix: cannot put a non-pointer in a gsl::not_null
2025-02-12 09:16:05 -06:00
Carson Radtke
7f4fc9388b Add more gsl::span tests [copilot] (#1189)
* 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
2025-02-12 09:15:43 -06:00
Tiago
355982daf6 Delete gsl/string_span (#1185)
This has been deprecated for 2+ years.
2025-01-07 08:58:59 -06:00
Werner Henze
50aaf2efbb remove documentation for deprecated make_span overloads (#1183)
Co-authored-by: Werner Henze <werner.henze+gitcommits@posteo.de>
2025-01-07 08:50:49 -06:00
Tiago
7b6b8013b1 Add "gsl" to #includes (#1184)
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.
2025-01-07 08:42:38 -06:00
Werner Henze
1cdb8d295e More checks for non-compilable code, plus fix for span (#1180) 2025-01-04 11:50:31 -06:00
Carson Radtke
c832885f15 React to ubuntu-latest changing to 24.04 (#1181)
* React to ubuntu-latest changing to 24.04
Reacting to https://github.com/actions/runner-images/issues/10636
* update clang to 16,17,18
* update gcc to 12,13,14
2025-01-03 10:23:50 -06:00
Werner Henze
16a60199df strict_not_null for unique_ptr (#1179)
- `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>
2024-12-26 11:00:36 -06:00
Werner Henze
fcd55ee924 Better use of std::enable_if (#1177)
* this commits adds tests that should fail, but don't

* Better use of std::enable_if

Replace the occurances of `class = std::enable_if_t<Cond>` and `typename = std::enable_if_t<Cond>` that have been identified in the previous commit with `std::enable_if_t<Cond, bool> = true`.

This commit is inspired by #1174, which changed one occurance in the owner header. This commit is aimed to fix all remaining occurances.

* fix failing checks

- core.cxx_gsl aktualisiert auf [](https://gitlab.avm.de/fos/repos/core.cxx_gsl/-/commit/)
- plc.access_lib aktualisiert auf [](https://gitlab.avm.de/fos/repos/plc.access_lib/-/commit/)
- plc.common aktualisiert auf [](https://gitlab.avm.de/fos/repos/plc.common/-/commit/)
- plc.daemon aktualisiert auf [](https://gitlab.avm.de/fos/repos/plc.daemon/-/commit/)
-

Test Plan:
-

---------

Co-authored-by: Werner Henze <werner.henze+gitcommits@posteo.de>
Co-authored-by: Werner Henze <w.henze@avm.de>
2024-12-23 10:40:22 -06:00
Werner Henze
b8ac820fe1 Force unit tests for byte to use GSL implementation (#1176)
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>
2024-12-18 10:16:36 -06:00
Carson Radtke
272463043e introduce gsl::swap for swapping gsl::not_null (#1160)
fixes: https://github.com/microsoft/GSL/issues/1129

* create gsl::swap<T>(T&, T&) which wraps std::swap
* specialize gsl::swap<T>(gsl::not_null<T>&, gsl::not_null<T>&)
* add tests
2024-12-13 15:16:53 -06:00
Carson Radtke
8a0e3d8a9b fix: direct-init const ref instead of list-init (#1175)
fixes: https://github.com/microsoft/GSL/issues/1162

gcc has a bug that generates a call to the copy constructor when list
initializing a const reference. This PR offers a workaround which is to
direct initialize the value.

see: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=117900
2024-12-13 10:22:16 -06:00
Alberto La Rocca
aed09c41b6 Fix SFINAE on gsl::owner. (#1174)
`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
2024-12-13 09:56:28 -06:00
Carson Radtke
4b190d2e2a Create issue templates (#1173) 2024-12-02 14:34:38 -06:00
Carson Radtke
ddae9d72b6 fix stale badge links in README (#1170)
* update pipeline badge links
* add link to compilers pipeline
* add badge to vcpkg version
2024-11-25 13:06:02 -06:00
Carson Radtke
74d2bb79d4 fix various pipeline failures (#1172)
* 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)
2024-11-25 12:58:45 -06:00
Carson Radtke
f8ec309118 improve performance of span_iterator w/ clang (#1166)
* 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
2024-11-12 15:41:21 -06:00
Carson Radtke
87f9d76886 GSL v4.1.0 (#1163)
Fixes: #1161

Update version strings in README and CMakeLists.txt.
v4.1.0
2024-10-21 10:19:37 -05:00
Heiko Kröger
82ba6c77ce Added the IWYU pragma export (#1154)
* Added the IWYU pragma export

clang-tidy has added the check misc-include-cleaner with version 17. This check respects the IWYU pragmas.
2024-10-15 17:26:45 -05:00
mq白
32511b8de4 Delete the useless 'noexcept(false)' (#1152) 2024-10-14 15:30:40 -05:00
Konstantin Akimov
84b2ca1352 Remove unused headers from gsl/pointers (#1153)
* 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
2024-10-14 15:15:46 -05:00
Carson Radtke
ce2a959e02 [ci]: add testing pipelines to github actions (#1159)
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)
2024-10-14 15:05:13 -05:00
Brian Kroth
11fe02d1ac Add a MS GSL disambiguation note (#1156) 2024-10-14 09:43:43 -05:00
Werner Henze
3275f9ccb9 Fix gcc build problem (#1149)
Closes issue #1148 by fixing problems introduced in PR #1140.

Co-authored-by: Werner Henze <w.henze@avm.de>
2024-10-11 19:46:21 -05:00
Carson Radtke
b206bd163b [ci]: fix android job (#1158)
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.
2024-10-11 16:05:20 -07:00
Werner Henze
b39e7e4b09 Add documentation for to_integer(byte) (#1144)
Co-authored-by: Werner Henze <w.henze@avm.de>
2024-02-26 13:23:45 -08:00
Stephan T. Lavavej
2e0d1ba48c Test only __cpp_lib_byte, drop _HAS_STD_BYTE. (#1145) 2024-02-26 13:22:20 -08:00
d-winsor
1b4d42ca2e Fix initialization in test (#1140)
* Suppress unsafe-buffer-usage
2024-02-26 13:17:12 -08:00
Bruce Mitchener
caae4dd0f8 Fix some typos. (#1146) 2024-02-21 15:06:29 -08:00
Bruce Mitchener
f1a494cfd2 ci: Update to actions/checkout@v4. (#1142)
This fixes annotations on task runs like the following:

    The following actions uses node12 which is deprecated and will be forced
    to run on node16: actions/checkout@v2. For more info:
    https://github.blog/changelog/2023-06-13-github-actions-all-actions-will-run-on-node16-instead-of-node12-by-default/
2024-01-17 15:25:32 -08:00
Bruce Mitchener
77b2f4f3b8 Fix some typos. (#1143) 2024-01-17 15:25:07 -08:00
Nicholas Guriev
e64c97fc2c Mark not_null constructors as noexcept when underlying type can be moved with no exception (#1135)
This enables possible optimisations for trivial types. This also avoids a bug
in std::variant::emplace from GNU's libstdc++.

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106547
2023-10-18 15:15:26 -07:00