mirror of
https://gitee.com/openharmony/third_party_rust_cxx
synced 2024-11-27 01:11:38 +00:00
Merge pull request #602 from dtolnay/slice
Obtain accurate alignment for empty slice of opaque Rust type
This commit is contained in:
commit
b97573b4e1
@ -146,6 +146,8 @@ pub(super) fn write(out: &mut OutFile) {
|
||||
out.next_section();
|
||||
writeln!(out, "template <typename T>");
|
||||
writeln!(out, "::std::size_t size_of();");
|
||||
writeln!(out, "template <typename T>");
|
||||
writeln!(out, "::std::size_t align_of();");
|
||||
}
|
||||
|
||||
ifndef::write(out, builtin.rust_string, "CXXBRIDGE1_RUST_STRING");
|
||||
|
@ -521,7 +521,8 @@ inline std::size_t Str::length() const noexcept { return this->len; }
|
||||
#ifndef CXXBRIDGE1_RUST_SLICE
|
||||
#define CXXBRIDGE1_RUST_SLICE
|
||||
template <typename T>
|
||||
Slice<T>::Slice() noexcept : ptr(reinterpret_cast<T *>(alignof(T))), len(0) {}
|
||||
Slice<T>::Slice() noexcept
|
||||
: ptr(reinterpret_cast<T *>(align_of<T>())), len(0) {}
|
||||
|
||||
template <typename T>
|
||||
Slice<T>::Slice(T *s, std::size_t count) noexcept : ptr(s), len(count) {}
|
||||
|
Loading…
Reference in New Issue
Block a user