#[allow(deprecated)]
impl Default for VectorOf{{{rust_type}}} {
fn default() -> Self {
let mut this = unsafe{ mem::zeroed() };
let this_ref = &mut this;
unsafe {
cpp!([this_ref as "std::vector<{{{cpp_type}}}>*"] {
new (this_ref) const std::vector<{{{cpp_type}}}>;
})
}
this
}
}
#[allow(deprecated)]
impl VectorSlice for VectorOf{{{rust_type}}} {
type Item = {{{rust_type}}};
fn get_ptr(&self) -> *const Self::Item {
unsafe {
cpp!([self as "const std::vector<{{{cpp_type}}}>*"]
-> *const {{{rust_type}}} as "const {{{cpp_type}}}*" {
return self->data();
})
}
}
fn get_mut_ptr(&mut self) -> *mut Self::Item {
unsafe {
cpp!([self as "std::vector<{{{cpp_type}}}>*"]
-> *mut {{{rust_type}}} as "{{{cpp_type}}}*" {
return self->data();
})
}
}
fn size(&self) -> usize {
unsafe {
cpp!([self as "const std::vector<{{{cpp_type}}}>*"] -> size_t as "size_t" {
return self->size();
})
}
}
}
#[allow(deprecated)]
impl VectorErase for VectorOf{{{rust_type}}} {
fn erase_range(&mut self, offset: usize, size: usize) {
let begin = offset as size_t;
let end = offset + size as size_t;
unsafe {
cpp!([self as "std::vector<{{{cpp_type}}}>*", begin as "size_t", end as "size_t"] {
self->erase(self->begin() + begin, self->begin() + end);
});
}
}
}
#[allow(deprecated)]
impl VectorInsert<{{{rust_type}}}> for VectorOf{{{rust_type}}} {
fn push_back(&mut self, mut v: Self::Item) {
let vref = &mut v;
unsafe {
cpp!([self as "std::vector<{{{cpp_type}}}>*", vref as "{{{cpp_type}}}*"] {
self->push_back(std::move(*vref));
})
}
mem::forget(v);
}
}
#[allow(deprecated)]
impl VectorExtract<{{{rust_type}}}> for VectorOf{{{rust_type}}} {
fn extract(&mut self, index: usize) -> {{{rust_type}}} {
assert!(index < self.size());
let mut v: {{{rust_type}}} = unsafe { mem::zeroed() };
let vref = &mut v;
unsafe {
cpp!([self as "std::vector<{{{cpp_type}}}>*", index as "size_t", vref as "{{{cpp_type}}}*"] {
*vref = std::move((*self)[index]);
})
}
v
}
}
add_impl!(VectorOf{{{rust_type}}});