mirror of
https://github.com/microsoft/GSL.git
synced 2026-08-06 13:44:09 +02:00
Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| efaafc26d4 | |||
| 835e39e3e4 | |||
| 9899e0e325 | |||
| 8b56e20958 |
@@ -61,7 +61,7 @@ jobs:
|
||||
xcode:
|
||||
strategy:
|
||||
matrix:
|
||||
xcode_version: [ '16.4' ]
|
||||
xcode_version: [ '26.6' ]
|
||||
build_type: [ Debug, Release ]
|
||||
cxx_version: [ 14, 17, 20, 23 ]
|
||||
runs-on: macos-latest
|
||||
@@ -88,9 +88,13 @@ jobs:
|
||||
# Regular MSVC builds use Ninja (from preset)
|
||||
- toolset: 'msvc'
|
||||
generator_override: ''
|
||||
# ClangCL builds require Visual Studio generator
|
||||
- toolset: 'ClangCL'
|
||||
# ClangCL builds require Visual Studio generator; version depends on image
|
||||
- image: windows-2022
|
||||
toolset: 'ClangCL'
|
||||
generator_override: '-G "Visual Studio 17 2022" -T ClangCL'
|
||||
- image: windows-2025
|
||||
toolset: 'ClangCL'
|
||||
generator_override: '-G "Visual Studio 18 2026" -T ClangCL'
|
||||
runs-on: ${{ matrix.image }}
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
|
||||
+5
-4
@@ -158,7 +158,7 @@ Convert the given value `I` to a `byte`. The template requires `I` to be in the
|
||||
|
||||
## <a name="H-dyn_array" />`<dyn_array>`
|
||||
|
||||
This header contains an owning dynamically allocated array type whose size is fixed at construction.
|
||||
This header contains an owning dynamically allocated array type whose size is fixed between assignments.
|
||||
|
||||
- [`gsl::dyn_array`](#user-content-H-dyn_array-dyn_array)
|
||||
|
||||
@@ -170,7 +170,7 @@ class dyn_array;
|
||||
```
|
||||
|
||||
`gsl::dyn_array` owns a contiguous sequence of `T` objects allocated with `Allocator`.
|
||||
The number of elements is established when the object is constructed and remains unchanged.
|
||||
The number of elements is established when the object is constructed and remains unchanged until the object is copy-assigned.
|
||||
It provides bounds-checked element access and checked random-access iterators.
|
||||
|
||||
`gsl::dyn_array` is useful when the number of elements is known only at runtime, but the array should not grow or shrink through container operations.
|
||||
@@ -242,7 +242,8 @@ constexpr dyn_array(dyn_array&&) = delete;
|
||||
dyn_array& operator=(dyn_array&&) = delete;
|
||||
```
|
||||
|
||||
Copy assignment, move assignment, and move construction are explicitly deleted.
|
||||
Copy assignment replaces the contents with copies of the elements in `other`.
|
||||
Move construction and move assignment are explicitly deleted.
|
||||
|
||||
##### Observers
|
||||
|
||||
@@ -299,7 +300,7 @@ constexpr auto crend() const;
|
||||
|
||||
Returns a reverse iterator to the first element of the reversed range or to one past the last element of the reversed range.
|
||||
|
||||
The iterators are random-access iterators and perform bounds checking; they can never be invalidated.
|
||||
The iterators are random-access iterators and perform bounds checking.
|
||||
Dereferencing `end()`, moving before `begin()` or past `end()`, or comparing iterators from different arrays violates preconditions.
|
||||
|
||||
##### Comparisons
|
||||
|
||||
@@ -31,6 +31,9 @@
|
||||
#if defined(__clang__)
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Winvalid-noreturn"
|
||||
#if __clang_major__ >= 22
|
||||
#pragma clang diagnostic ignored "-Wunique-object-duplication"
|
||||
#endif // __clang_major >= 22
|
||||
#endif // defined(__clang__)
|
||||
|
||||
#else // defined(_MSC_VER) && (defined(_KERNEL_MODE) || (defined(_HAS_EXCEPTIONS) &&
|
||||
|
||||
@@ -216,9 +216,8 @@ namespace details
|
||||
|
||||
constexpr auto operator++(int)
|
||||
{
|
||||
auto rv = *this;
|
||||
++(*this);
|
||||
return rv;
|
||||
return dyn_array_iterator{_ptr, _pos - 1, _end_pos};
|
||||
}
|
||||
|
||||
constexpr auto operator--() -> dyn_array_iterator&
|
||||
@@ -230,9 +229,8 @@ namespace details
|
||||
|
||||
constexpr auto operator--(int)
|
||||
{
|
||||
auto rv = *this;
|
||||
--(*this);
|
||||
return rv;
|
||||
return dyn_array_iterator{_ptr, _pos + 1, _end_pos};
|
||||
}
|
||||
|
||||
constexpr auto operator+=(difference_type diff) -> dyn_array_iterator&
|
||||
|
||||
@@ -133,6 +133,12 @@ namespace details
|
||||
} // namespace details
|
||||
|
||||
// final_action allows you to ensure something gets run at the end of a scope
|
||||
// The bool member causes trailing padding when F has alignment > 1; suppress
|
||||
// -Wpadded since the padding is unavoidable for a generic callable wrapper.
|
||||
#if defined(__clang__)
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wpadded"
|
||||
#endif // defined(__clang__)
|
||||
template <class F>
|
||||
class final_action
|
||||
{
|
||||
@@ -157,6 +163,9 @@ private:
|
||||
F f;
|
||||
bool invoke = true;
|
||||
};
|
||||
#if defined(__clang__)
|
||||
#pragma clang diagnostic pop
|
||||
#endif // defined(__clang__)
|
||||
|
||||
// finally() - convenience function to generate a final_action
|
||||
template <class F>
|
||||
|
||||
@@ -54,6 +54,14 @@ if (NOT GTestMain_FOUND)
|
||||
${CMAKE_CURRENT_BINARY_DIR}/googletest-build
|
||||
EXCLUDE_FROM_ALL
|
||||
)
|
||||
|
||||
# googletest is built as its own target, so apply this workaround there.
|
||||
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang"
|
||||
AND CMAKE_CXX_SIMULATE_ID STREQUAL "MSVC"
|
||||
AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 22)
|
||||
target_compile_options(gtest PRIVATE -Wno-character-conversion)
|
||||
target_compile_options(gtest_main PRIVATE -Wno-character-conversion)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if (CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)
|
||||
@@ -111,7 +119,7 @@ if(MSVC) # MSVC or simulating MSVC
|
||||
-Wno-undef # GTest
|
||||
-Wno-used-but-marked-unused # GTest EXPECT_DEATH
|
||||
-Wno-switch-default # GTest EXPECT_DEATH
|
||||
$<$<EQUAL:${GSL_CXX_STANDARD},14>: # no support for [[maybe_unused]]
|
||||
$<$<EQUAL:${GSL_CXX_STANDARD},14>: # no support for [[maybe_unused]]
|
||||
-Wno-unused-member-function
|
||||
-Wno-unused-variable
|
||||
$<$<VERSION_EQUAL:$<CXX_COMPILER_VERSION>,15.0.1>:
|
||||
|
||||
@@ -189,6 +189,10 @@ TEST(dyn_array_tests, ranges)
|
||||
#endif /* __cpp_lib_ranges >= 201911L */
|
||||
|
||||
#if defined(__cpp_lib_constexpr_dynamic_alloc) && (__cpp_lib_constexpr_dynamic_alloc >= 201907L)
|
||||
#if defined(__clang__)
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wpadded"
|
||||
#endif // defined(__clang__)
|
||||
template <typename T, unsigned N>
|
||||
struct ConstexprAllocator
|
||||
{
|
||||
@@ -218,6 +222,9 @@ struct ConstexprAllocator
|
||||
|
||||
constexpr void deallocate(value_type*, std::size_t) noexcept {}
|
||||
};
|
||||
#if defined(__clang__)
|
||||
#pragma clang diagnostic pop
|
||||
#endif // defined(__clang__)
|
||||
|
||||
template <typename T1, unsigned N1, typename T2, unsigned N2>
|
||||
constexpr auto operator==(const ConstexprAllocator<T1, N1>& lhs,
|
||||
|
||||
Reference in New Issue
Block a user