Commit Graph

15 Commits (4e7fa91b9470b1a764a3ebae7e6cfc92215d9323)

Author SHA1 Message Date
Vincent Coubard 4e7fa91b94 Span: amend documentation 2018-08-22 15:11:27 +01:00
Vincent Coubard 95fc284a83 Span: add boundary check in subscript operator for debug profile 2018-08-22 13:32:54 +01:00
Vincent Coubard f6dd5eaa31 Span: Fix static assert message in default constructor. 2018-08-22 13:31:26 +01:00
Vincent Coubard 26b546bab3 Span: Improve readability of precondition checks 2018-08-22 09:40:51 +01:00
Vincent Coubard 938d802ea0 Span: Fix subspan return type 2018-08-22 09:40:50 +01:00
Vincent Coubard 54e2d92c95 Span: Improve consistency with standard.
This commit aims to make Span implementation more in line with what is present in N4762:
- use appropiate index types where applicable.
- use typedefed type inside the class (index_type, reference, pointer, element_type)
- assertion where applicable
- restrict default construction to Span with extent == 0 or extent == dynamic.
- construct span from a range of pointer
- remove non const overload of the subscript operator
- remove non const overload of the data function
- implement subspan function
- implement missing first and last function of dynamic span
2018-08-21 18:20:58 +01:00
Vincent Coubard 3985fb8d62 Span: Fix documentation error. 2018-08-20 12:00:20 +01:00
Vincent Coubard 1f00336c7e Span: replace reference to Size with Extent. 2018-08-20 11:58:48 +01:00
Vincent Coubard 6fcf1e8284 Span: Make type pointer and reference declaration consistent with guideline. 2018-08-20 10:47:41 +01:00
Vincent Coubard 9b9d33a7b4 Span: Fix typo. 2018-08-20 10:41:47 +01:00
Vincent Coubard 3fb3173876 Span: Fix odd condition in Span::empty. 2018-08-20 10:30:35 +01:00
Vincent Coubard 43170d21bf Span: Make name of dynamic span tag consistent with C++ standard. 2018-08-20 10:29:43 +01:00
Vincent Coubard eba1dc6dd6 Span: Improve comparison operator to array by using fixed size Span. 2018-08-20 09:13:31 +01:00
Vincent Coubard 7f195b8ec1 Span: Cleanup usage of ptrdiff_t and size_t 2018-08-20 09:13:17 +01:00
Vincent Coubard d8c788a413 Platform: Add C++ Span class.
The Span class allows the creation of views over contiguous memory. The view
do not own memory, is typed and has a length. It can be used as a replacement of
the traditional pair of pointer and size in parameters or class fields.

Main operations:
- size(): return the lenght of the memory viewed
- empty(): return if the memory viewed is empty
- [index]: access elements viewed
- data(): return a pointer to the memory viewed.
- first(count): Create a subview from the first count elements.
- last(count): Create a subview from the last count elements.
- == and !=: compare two views or a view to array and return if they are equal or
not.

The Span class came in two flavors:
- Static size: The size is encoded in the Span type and it is as lightweitgh as
a single pointer,
- Dynamic size: The object can store arbitrary views and it costs one pointer
and the size of the view.
2018-08-19 20:20:05 +01:00