Commit Graph

138 Commits

Author SHA1 Message Date
Dmitry Kobets
9face82309
Remove unnecessary check from size_bytes() (#1105)
`size_bytes()` returns the span's size in bytes. 
Assuming the span was constructed with an accurate size parameter, the check `size() < dynamic_extent / sizeof(element_type)` isn't required, since `size_t(-1)` (which is `dynamic_extent`) represents the size of the address space, so the number of bytes will never exceed it and in practice won't even come close.
Otherwise, it is not actually feasible to detect cases when the size parameter does not correspond to the dimensions of the underlying data pointer. In these cases, the relationship `size() < dynamic_extent / sizeof(element_type)` is simply one of many ways in which the `size()` could be incorrect, and serves no necessary purpose.

Resolves #1012
2023-05-09 09:05:26 -07:00
Werner Henze
43d60c5e38
Suppress warning C26481 (#1099)
Suppress "warning C26481: Don't use pointer arithmetic. Use span instead (bounds.1)." in the code that impements `span`.
2023-03-14 16:57:46 -07:00
Stephan T. Lavavej
50d6eef541
Add span_iterator::_Prevent_inheriting_unwrap. (#1100) 2023-03-14 13:50:34 -07:00
Werner Henze
10df83d292
solve span compile problem with gcc 5.5.0 (#1052)
GCC 4.8.0 - 7.0 has a bug (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56480) involving specialization in a namespace enclosing the specialized template. This PR fixes an appearance of this bug in the span header.
2022-08-18 12:28:11 -07:00
dmitrykobets-msft
da01eb28db
Remove useless runtime checks in span implementation (#1029)
Both checks for Expects(ExtentType::size() != dynamic_extent); in storage_type are always useless. storage_type<ExtentType> is only ever created with ExtentType == extent_type<Extent>, where Extent has type std::size_t and is the extent of the span.

Looking at extent_type<std::size_t Ext>::size():

- if Ext != dynamic_extent, then size() always returns Ext, and therefore size() != dynamic_extent
- if Ext == dynamic_extent, then size() returns extent_type<dynamic_extent>::size_. size_ can only be set via one of two constructors:
  - constexpr explicit extent_type(size_type size), which already does the check in question
  - constexpr explicit extent_type(extent_type<Other> ext) : size_(ext.size()), which simply relies on the other extent's size() method
So there is no way for ExtentType::size() == dynamic_extent.
2022-04-28 14:58:25 -07:00
dmitrykobets-msft
383723676c
Make gsl::span's iterators use the contiguous_iterator concept (#1035)
Resolves #1016

Co-authored-by: Casey Carter <Casey@Carter.net>
2022-03-22 13:20:54 -07:00
Werner Henze
4377f6e603
quoted form of #include when GSL includes GSL files (#1030)
[SF.12: Prefer the quoted form of #include for files relative to the including file and the angle bracket form everywhere else](https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#Rs-incform)

Additionally changed #include order in `span` so that all `span_ext` is in the GSL include block and not in the STL include block.

Fixes issues #1025.

Co-authored-by: Werner Henze <w.henze@avm.de>
2022-01-31 13:06:42 -08:00
Jordan Maples [MSFT]
b26f6d5ec7
gsl::at behavior change regarding gsl::span (#985)
* move span specialization of 'at' to <gsl/span> and update the parameter to be taken by reference

* undid previous changes and acted upon decisions made in maintainer sync. Fixed tests failing in /kernel mode

* ran clang-format on the include folder

* ran clang-format on the test folder

Co-authored-by: Jordan Maples <jordan.maples@microsoft.com>
2021-05-20 18:18:08 -07:00
beinhaerter
00d4a5aab6
suppress bounds.1 (#950)
Suppress "warning C26481: Don't use pointer arithmetic. Use span instead (bounds.1)."

Co-authored-by: Werner Henze <werner.henze+gitcommits@posteo.de>
2020-11-11 13:47:58 -08:00
Jordan Maples [MSFT]
a150aaa4ed
renaming main logic files. Added warning message of the removal and include passthrough. Renamed includes in the source files. Ran Clang-Format (#946)
Header rename
2020-10-29 17:38:48 -07:00
Jordan Maples [MSFT]
2c3ab0211c
Fix C26481 warning in span array ctor (#944)
* Azure pipeline (#8)

* azure-pipeline test

* nl @ eof

* trimming the pipeline and adding debug steps

* removing redundant lines

* change ctest to script cmd and remove debug

* removed bad char

* added dir change for ctest

* explicit output file and cmake standard

* test cat

* more ctest tests

* injecting failure in test for validation

* another test

* removing bad test

* massive matrix

* added parallel

* commenting everything but xcode out for testing purposes

* uncomment the other tests

* testing some variables

* rename

* changed macos versions

* adding one more layer of templates

* fixing jobs.yml

* idk what i'm doing

* slight modifications

* maybe some spaces will help

* removing 'variables.'

* another test

* adding back pr w/ autocancel

* adding failing test to validate error = failing task

* remove failing test

* trigger master

* nl in steps.yml

* remove forced decay of array reference to pointer in span array ctor
2020-10-29 10:54:37 -07:00
tjs137
8009a703c2
use narrow_cast 2020-10-24 19:44:06 -04:00
beinhaerter
2af9b11fe9
Update include/gsl/span
Co-authored-by: Jordan Maples [MSFT] <49793787+JordanMaples@users.noreply.github.com>
2020-10-20 00:44:11 +02:00
beinhaerter
dc6fdff4c0
Update include/gsl/span
Co-authored-by: Jordan Maples [MSFT] <49793787+JordanMaples@users.noreply.github.com>
2020-10-20 00:44:02 +02:00
Werner Henze
2ccf36b4b9 eliminate warning, use narrow_cast instead of static_cast 2020-10-14 15:04:50 +02:00
Jordan Maples
4c66cea06c remove gsl namespace qualification within the gsl namespace 2020-07-15 13:11:57 -07:00
Casey Carter
c143a07f61 Add string_view test case and modify deduction guides 2020-05-28 18:00:40 -07:00
Jordan Maples
689abc2982 adding container ctad 2020-05-28 14:04:31 -07:00
Jordan Maples [MSFT]
0dbdf322fa
Merge pull request #886 from JordanMaples/dev/jomaples/build_matrix
compiler support revision
2020-05-26 15:14:08 -07:00
Jordan Maples [MSFT]
283e31478f
Merge pull request #857 from pps83/master-natvis
Fix debugger visualizer for Ext=gsl::dynamic_extent
2020-05-21 11:32:45 -07:00
Jordan Maples
25e7af9c7d fixing clang build break 2020-05-20 17:52:03 -07:00
Jordan Maples
7e4ed8da98 addressing Stephan's comments 2020-05-20 16:50:50 -07:00
Jordan Maples
313a1121bf fix spacing 2020-05-20 15:46:20 -07:00
Jordan Maples
1e44481646 Finished integrating CaseyCarter's changes into span 2020-05-20 13:37:42 -07:00
Jordan Maples
ed3fea6d93 implementing some of Casey's recommendations 2020-05-20 13:11:37 -07:00
Jordan Maples
d3468230b1 renaming extent to prevent shadowing of static member 2020-05-20 12:29:56 -07:00
Jordan Maples
552cd20472 addressing most of Casey's comments 2020-05-20 10:59:57 -07:00
Jordan Maples
2085c7acde initial impl of P1976R2 2020-05-19 16:27:46 -07:00
Jordan Maples
f0160fcb1b removing breaking test code. removing compiler versions n-2 and beyond from travis script. Updating XCode 11.3 to 11.4 2020-05-13 14:49:17 -07:00
Jordan Maples [MSFT]
2a483c1728
Update span 2020-05-13 11:13:14 -07:00
Jordan Maples
031231466d pushing bad code that only reveals itself in gcc < 6 to test the allow_failures logic in travis 2020-05-13 11:04:11 -07:00
Jordan Maples
09caa20d99 changing matrices and removing msc < 1910 work arounds 2020-05-12 16:21:55 -07:00
Jordan Maples [MSFT]
1999b48a51
Merge pull request #870 from beinhaerter/suppress_span_warning
suppress code analysis warning
2020-04-23 10:13:33 -07:00
Nicholas Londey
14acdcd7a8 Removed unused #include 2020-04-23 12:22:30 +10:00
Werner Henze
fb1243d735 suppress code analysis warning
- suppress " warning C26481: Don't use pointer arithmetic. Use span instead (bounds.1)."
- Please note that the suppression in `end()` does not work with MSVC 16.5.4.
2020-04-19 16:41:12 +02:00
Jordan Maples
7341c5d1b5 implement LWG3320 by deleting const_iterator and const_reverse_iterator 2020-04-14 13:51:49 -07:00
Pavel P
830b081de7 Fix debugger visualizer for Ext=gsl::dynamic_extent
VS 2019 doesn't seem to match -1 for size_t template parameter, as a result dynamic span/basic_string_span/basic_zstring_span show extent as `extent = 4294967295` (for 32-bit builds). This change updates details::extent_type to have static constexpr size_ parameter for non-dynamic span/basic_string_span/basic_zstring_span and simplifies/removes dynamic versions from GSL.natvis

fixes #856
2020-03-28 01:59:04 +06:00
Jordan Maples
f8bcb7d9eb applied clang-format 2020-03-17 15:04:58 -07:00
Jordan Maples
9b3ac8d681 discussed the issue with Casey Carter, the span ctor changes are accurate but the tests are not. The test require work that was done in C++17 regarding qualifier conversions to work correctly. Scoping tests for 17. 2020-03-17 15:02:00 -07:00
Jordan Maples
1dd1320c8b test commit to get extra eyes on the problem 2020-03-17 13:53:13 -07:00
Jordan Maples [MSFT]
4a6a7a095d add back array header, will remove in separate pr 2020-02-25 14:09:29 -08:00
Jordan Maples [MSFT]
fc54e0d89a just pulling in array header if we detect apple clang 2020-02-25 13:39:47 -08:00
Jordan Maples [MSFT]
32e5fea6ac test 2020-02-24 14:47:45 -08:00
Jordan Maples [MSFT]
0f60c68ab9 disgusting test to get apple clang to work, dont look at it 2020-02-24 14:41:29 -08:00
Jordan Maples [MSFT]
60372b6468 apple-clang failed again, forcing class instead of struct 2020-02-24 13:43:42 -08:00
Jordan Maples [MSFT]
89271b89c1 fix apple clang forward declaration 2020-02-24 13:06:01 -08:00
Jordan Maples [MSFT]
ac37004274 clang defines struct as array where msvc and g++ define it as class. 2020-02-24 11:45:33 -08:00
Jordan Maples [MSFT]
3144082909 forward declare span and remove header 2020-02-24 11:16:26 -08:00
Jordan Maples [MSFT]
94f43d4adf splitting up span's standard and non-standard behavior 2020-02-19 14:28:12 -08:00
Jordan Maples [MSFT]
46603698ec rewrite operators in iterator to take advantage of nrvo 2020-02-18 15:36:15 -08:00