cpp/numeric/valarray/slice

is the selector class that identifies a subset of std similar to slice. An object of type holds three values: the starting index, the stride, and the total number of values in the subset. Objects of type can be used as indexes with valarray's.

Member functions
{{member|{{small|std::slice::}}slice| {{dcl begin}} {{dcl|num=1| slice }} {{dcl|num=2| slice( std::size_t start, std::size_t size, std::size_t stride ); }} {{dcl|num=3| slice( const slice& other ); }} {{dcl end}}

Constructs a new slice.

@1@ Default constructor. Equivalent to {{c|slice(0, 0, 0)}}. This constructor exists only to allow construction of arrays of slices.

@2@ Constructs a new slice with parameters {{c|start}}, {{c|size}}, {{c|stride}}. This slice will refer to {{c|size}} number of elements, each with the position:



@3@ Constructs a copy of {{c|other}}.

Parameters
}}

{{member|{{small|std::slice::}}start, size, stride| {{dcl begin}} {{dcl|num=1| std::size_t start const; }} {{dcl|num=2| std::size_t size const; }} {{dcl|num=3| std::size_t stride const; }} {{dcl end}}

Returns the parameters passed to the slice on construction - start, size and stride respectively.

Parameters
(none)

Return value
The parameters of the slice -- start, size and stride respectively.

Complexity
Constant. }}

Non-member functions
{{member|1=operator=={{petty|(std::slice)}}|2= {{dcl begin}} {{dcl|since=c++20|1= friend bool operator==( const slice& lhs, const slice& rhs ); }} {{dcl end}}

Checks if the parameters of {{c|lhs}} and {{c|rhs}} - start, size and stride are equal respectively.

{{cpp/hidden friend|std::slice}}

{{cpp/note synthesized eq}}

Return value
}}