Obtain accurate alignment for empty slice of opaque Rust type
diff --git a/gen/src/builtin.rs b/gen/src/builtin.rs
index 409a5d1..2e75666 100644
--- a/gen/src/builtin.rs
+++ b/gen/src/builtin.rs
@@ -146,6 +146,8 @@
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");
diff --git a/include/cxx.h b/include/cxx.h
index 8ca1a12..d795918 100644
--- a/include/cxx.h
+++ b/include/cxx.h
@@ -521,7 +521,8 @@
#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) {}