| 731 | |
| 732 | template <typename T, ssize_t Dims> |
| 733 | class unchecked_mutable_reference : public unchecked_reference<T, Dims> { |
| 734 | friend class pybind11::array; |
| 735 | using ConstBase = unchecked_reference<T, Dims>; |
| 736 | using ConstBase::ConstBase; |
| 737 | using ConstBase::Dynamic; |
| 738 | |
| 739 | public: |
| 740 | // Bring in const-qualified versions from base class |
| 741 | using ConstBase::operator(); |
| 742 | using ConstBase::operator[]; |
| 743 | |
| 744 | /// Mutable, unchecked access to data at the given indices. |
| 745 | template <typename... Ix> |
| 746 | T &operator()(Ix... index) { |
| 747 | static_assert(ssize_t{sizeof...(Ix)} == Dims || Dynamic, |
| 748 | "Invalid number of indices for unchecked array reference"); |
| 749 | return const_cast<T &>(ConstBase::operator()(index...)); |
| 750 | } |
| 751 | /** |
| 752 | * Mutable, unchecked access data at the given index; this operator only participates if the |
| 753 | * reference is to a 1-dimensional array (or has runtime dimensions). When present, this is |
| 754 | * exactly equivalent to `obj(index)`. |
| 755 | */ |
| 756 | template <ssize_t D = Dims, typename = enable_if_t<D == 1 || Dynamic>> |
| 757 | T &operator[](ssize_t index) { |
| 758 | return operator()(index); |
| 759 | } |
| 760 | |
| 761 | /// Mutable pointer access to the data at the given indices. |
| 762 | template <typename... Ix> |
| 763 | T *mutable_data(Ix... ix) { |
| 764 | return &operator()(ssize_t(ix)...); |
| 765 | } |
| 766 | }; |
| 767 | |
| 768 | template <typename T, ssize_t Dim> |
| 769 | struct type_caster<unchecked_reference<T, Dim>> { |
nothing calls this directly
no test coverage detected