This is a test of exporting with code
from org-mode
some required setup:
(org-babel-do-load-languages
'org-babel-load-languages '((C . t)))
using namespace std;
vector<int> foo{1, 2, 3};
copy(foo.begin(), foo.end(), ostream_iterator<int>(cout, " "));
You can go into the above code and type C-c C-c to have it compiled and the results inserted above this line.
Sometimes you need more than just a few includes or flags etc. to properly support your code block, but you don’t want to uglify your slides with the boilerplate. In that case we can define a hidden (unexported) scaffold code block that incorporates the one we display.
auto [s, i] = make_tuple("foo", 42);
The unexported scaffold would be visible below except that we used :exports none
(Note “noweb”, which enables including fragments via <<>>
)
This is pretty fun. You can put an inline table and supply it to some code:
Name | Years at C++Now |
---|---|
Jeff | 10 |
Marshall | 12 |
Michael | 10 |
Ben | 4 |
// sort by years
sort(begin(data), end(data),
[](auto const& a, auto const& b)
{
return get<1>(a) < get<1>(b);
}
);
for (auto const & nm_age: data)
{
cout << get<0>(nm_age) << ": " << get<1>(nm_age) << "\n";
}