Include <new> when placement new is used
diff --git a/gen/src/include.rs b/gen/src/include.rs
index 0ed76ac..4309c9c 100644
--- a/gen/src/include.rs
+++ b/gen/src/include.rs
@@ -56,6 +56,7 @@
pub cstring: bool,
pub exception: bool,
pub memory: bool,
+ pub new: bool,
pub string: bool,
pub type_traits: bool,
pub utility: bool,
@@ -106,6 +107,9 @@
if self.memory {
writeln!(f, "#include <memory>")?;
}
+ if self.new {
+ writeln!(f, "#include <new>")?;
+ }
if self.string {
writeln!(f, "#include <string>")?;
}
diff --git a/gen/src/write.rs b/gen/src/write.rs
index 2cf9faf..46b6151 100644
--- a/gen/src/write.rs
+++ b/gen/src/write.rs
@@ -149,11 +149,13 @@
for ty in types {
match ty {
Type::RustBox(_) => {
+ out.include.new = true;
out.include.type_traits = true;
needs_rust_box = true;
}
Type::RustVec(_) => {
out.include.array = true;
+ out.include.new = true;
out.include.type_traits = true;
needs_rust_vec = true;
}
@@ -463,6 +465,7 @@
write!(out, " ");
}
if indirect_return {
+ out.include.new = true;
write!(out, "new (return$) ");
write_indirect_return_type(out, efn.ret.as_ref().unwrap());
write!(out, "(");
@@ -1149,6 +1152,7 @@
// Shared by UniquePtr<T> and UniquePtr<CxxVector<T>>.
fn write_unique_ptr_common(out: &mut OutFile, ty: &Type, types: &Types) {
+ out.include.new = true;
out.include.utility = true;
let inner = to_typename(&out.namespace, ty);
let instance = to_mangled(&out.namespace, ty);
diff --git a/include/cxx.h b/include/cxx.h
index 9f4fb47..f211b3b 100644
--- a/include/cxx.h
+++ b/include/cxx.h
@@ -4,6 +4,7 @@
#include <cstdint>
#include <exception>
#include <iosfwd>
+#include <new>
#include <string>
#include <type_traits>
#include <utility>