Sleipnir C++ API
Loading...
Searching...
No Matches
slp::Slice Class Reference

#include <sleipnir/autodiff/slice.hpp>

Public Member Functions

constexpr Slice ()=default
 
constexpr Slice (slicing::none_t)
 
constexpr Slice (int start)
 
template<typename Start , typename Stop >
requires (std::same_as<Start, slicing::none_t> || std::convertible_to<Start, int>) && (std::same_as<Stop, slicing::none_t> || std::convertible_to<Stop, int>)
constexpr Slice (Start start, Stop stop)
 
template<typename Start , typename Stop , typename Step >
requires (std::same_as<Start, slicing::none_t> || std::convertible_to<Start, int>) && (std::same_as<Stop, slicing::none_t> || std::convertible_to<Stop, int>) && (std::same_as<Step, slicing::none_t> || std::convertible_to<Step, int>)
constexpr Slice (Start start, Stop stop, Step step)
 
constexpr int adjust (int length)
 

Public Attributes

int start = 0
 Start index (inclusive).
 
int stop = 0
 Stop index (exclusive).
 
int step = 1
 Step.
 

Detailed Description

Represents a sequence of elements in an iterable object.

Constructor & Destructor Documentation

◆ Slice() [1/5]

constexpr slp::Slice::Slice ( )
constexprdefault

Constructs a Slice.

◆ Slice() [2/5]

constexpr slp::Slice::Slice ( slicing::none_t  )
inlineconstexpr

Constructs a slice.

◆ Slice() [3/5]

constexpr slp::Slice::Slice ( int  start)
inlineconstexpr

Constructs a slice.

Parameters
startSlice start index (inclusive).

◆ Slice() [4/5]

template<typename Start , typename Stop >
requires (std::same_as<Start, slicing::none_t> || std::convertible_to<Start, int>) && (std::same_as<Stop, slicing::none_t> || std::convertible_to<Stop, int>)
constexpr slp::Slice::Slice ( Start  start,
Stop  stop 
)
inlineconstexpr

Constructs a slice.

Parameters
startSlice start index (inclusive).
stopSlice stop index (exclusive).

◆ Slice() [5/5]

template<typename Start , typename Stop , typename Step >
requires (std::same_as<Start, slicing::none_t> || std::convertible_to<Start, int>) && (std::same_as<Stop, slicing::none_t> || std::convertible_to<Stop, int>) && (std::same_as<Step, slicing::none_t> || std::convertible_to<Step, int>)
constexpr slp::Slice::Slice ( Start  start,
Stop  stop,
Step  step 
)
inlineconstexpr

Constructs a slice.

Parameters
startSlice start index (inclusive).
stopSlice stop index (exclusive).
stepSlice step.

Member Function Documentation

◆ adjust()

constexpr int slp::Slice::adjust ( int  length)
inlineconstexpr

Adjusts start and end slice indices assuming a sequence of the specified length.

Parameters
lengthThe sequence length.
Returns
The slice length.

The documentation for this class was generated from the following file: