mirror of
https://gitee.com/openharmony/third_party_rust_cxx
synced 2024-11-27 01:11:38 +00:00
Allow slice null ptr safely if slice is empty
This commit is contained in:
parent
96ee470356
commit
bb98d9eb09
@ -505,8 +505,12 @@ Slice<T>::Slice() noexcept {
|
||||
|
||||
template <typename T>
|
||||
Slice<T>::Slice(T *s, std::size_t count) noexcept {
|
||||
assert(s != nullptr);
|
||||
sliceInit(this, const_cast<typename std::remove_const<T>::type *>(s), count);
|
||||
assert(s != nullptr || count == 0);
|
||||
sliceInit(this,
|
||||
s == nullptr && count == 0
|
||||
? reinterpret_cast<void *>(align_of<T>())
|
||||
: const_cast<typename std::remove_const<T>::type *>(s),
|
||||
count);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
|
Loading…
Reference in New Issue
Block a user