wiki:C++Features

Version 3 (modified by Eric Pettersen, 2 months ago) ( diff )

--

Our Friend Otto auto

Simplify declarations; examples...

auto err_val = PyList_New(2);

for (auto node: ast.nodes) {

auto distance = (ast.choice == 0 ? eval_real_number : eval_integer)(*ast.nodes[1]);

for (auto i = 1u; I < ast.nodes.size(); ++i) {

Initializer Lists

For initializing containers:

static std::vector<std::string> symbols = { "&", "|" };

​Discussion

Raw Strings

For more easily specifying strings that have lots of special characters (think newlines and backslashes) such as regular expressions or parser grammars.

The basic syntax is:

R"(some complex string)"

Since in some situations the sequence )" might occur in the string, additional characters can be between the R and the ", e.g.:

R---"(some complex string)---"

​More discussion

Note: See TracWiki for help on using the wiki.