Skip to content

Instantly share code, notes, and snippets.

@sugar700
Created October 1, 2018 14:15
Show Gist options
  • Save sugar700/fe82e3fae79fddacf2d8119062098f01 to your computer and use it in GitHub Desktop.
Save sugar700/fe82e3fae79fddacf2d8119062098f01 to your computer and use it in GitHub Desktop.
#[macro_use]
extern crate cpp;
cpp! {{
#include <numeric>
#include <vector>
}}
fn main() {
let y = 3;
let x = unsafe {
cpp!([y as "int32_t"] -> i32 as "int32_t" {
auto x = std::vector<int32_t>{1, y, 3};
return std::accumulate(x.begin(), x.end(), 0);
})
};
println!("{}", x);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment