Created
October 1, 2018 14:15
-
-
Save sugar700/fe82e3fae79fddacf2d8119062098f01 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #[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