@@ -180,8 +180,6 @@ class Slice final
180
180
void swap (Slice &) noexcept ;
181
181
182
182
private:
183
- void *ptr () const noexcept ;
184
-
185
183
std::array<std::uintptr_t , 2 > repr;
186
184
};
187
185
@@ -487,26 +485,27 @@ constexpr unsafe_bitcopy_t unsafe_bitcopy{};
487
485
488
486
#ifndef CXXBRIDGE1_RUST_SLICE
489
487
#define CXXBRIDGE1_RUST_SLICE
488
+ void sliceInit (void *, const void *, std::size_t ) noexcept ;
489
+ void *slicePtr (const void *) noexcept ;
490
+ std::size_t sliceLen (const void *) noexcept ;
491
+
490
492
template <typename T>
491
493
Slice<T>::Slice() noexcept {
492
- void sliceInit (void *, const void *, std::size_t ) noexcept ;
493
494
sliceInit (this , reinterpret_cast <void *>(align_of<T>()), 0 );
494
495
}
495
496
496
497
template <typename T>
497
498
Slice<T>::Slice(T *s, std::size_t count) noexcept {
498
- void sliceInit (void *, const void *, std::size_t ) noexcept ;
499
499
sliceInit (this , const_cast <typename std::remove_const<T>::type *>(s), count);
500
500
}
501
501
502
502
template <typename T>
503
503
T *Slice<T>::data() const noexcept {
504
- return reinterpret_cast <T *>(this -> ptr ( ));
504
+ return reinterpret_cast <T *>(slicePtr ( this ));
505
505
}
506
506
507
507
template <typename T>
508
508
std::size_t Slice<T>::size() const noexcept {
509
- std::size_t sliceLen (const void *) noexcept ;
510
509
return sliceLen (this );
511
510
}
512
511
@@ -523,7 +522,7 @@ bool Slice<T>::empty() const noexcept {
523
522
template <typename T>
524
523
T &Slice<T>::operator [](std::size_t n) const noexcept {
525
524
assert (n < this ->size ());
526
- auto pos = static_cast <char *>(this -> ptr ( )) + size_of<T>() * n;
525
+ auto pos = static_cast <char *>(slicePtr ( this )) + size_of<T>() * n;
527
526
return *reinterpret_cast <T *>(pos);
528
527
}
529
528
@@ -663,7 +662,7 @@ bool Slice<T>::iterator::operator>=(const iterator &other) const noexcept {
663
662
template <typename T>
664
663
typename Slice<T>::iterator Slice<T>::begin() const noexcept {
665
664
iterator it;
666
- it.pos = this -> ptr ( );
665
+ it.pos = slicePtr ( this );
667
666
it.stride = size_of<T>();
668
667
return it;
669
668
}
@@ -679,12 +678,6 @@ template <typename T>
679
678
void Slice<T>::swap(Slice &rhs) noexcept {
680
679
std::swap (*this , rhs);
681
680
}
682
-
683
- template <typename T>
684
- void *Slice<T>::ptr() const noexcept {
685
- void *slicePtr (const void *) noexcept ;
686
- return slicePtr (this );
687
- }
688
681
#endif // CXXBRIDGE1_RUST_SLICE
689
682
690
683
#ifndef CXXBRIDGE1_RUST_BOX
0 commit comments