Template Function otyca::extract_by_indices
Function Documentation
-
template<typename T>
std::vector<T> otyca::extract_by_indices(const std::vector<T> &input, const std::vector<int> &indices) Extracts elements from a vector based on a list of indices.
This function creates a new vector containing elements from the input vector at the specified indices. If any index is out of range, an exception will be thrown.
- Template Parameters:
T – The type of the elements in the vector (e.g., int, float).
- Parameters:
input – The input vector from which elements will be extracted.
indices – The list of indices specifying the elements to extract.
- Throws:
std::out_of_range – If any of the indices are out of range.
- Returns:
A vector containing the extracted elements.