py::builtins::range::index¶
constexpr std::size_t index(const value_type& value) const;
Returns the index of given value.
Parameter¶
value: The value to look for.
Return value¶
The index of given element.
Exceptions¶
py-builtins-ValueError if the element can’t be found.
Complexity¶
Constant.
Example¶
#include <pypp/builtins/range.hpp>
#include <pypp/builtins/print.hpp>
int main()
{
py::range<int> nums(1, 10);
py::print(nums.index(5));
}
Output:
4