"We group here some small modern features, added to ease your developer life."
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"## At last, `>>` allowed for templates of templates\n",
"\n",
"When nesting template arguments, no more need to insert a space between subsequent \"<\" or \">\"."
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"## At last, default member variable initialization\n",
"\n",
"In a class or struct definition, one can now give a default value to any member variable."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"slideshow": {
"slide_type": "fragment"
}
},
"outputs": [],
"source": [
"#include <iostream>"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"slideshow": {
"slide_type": "fragment"
}
},
"outputs": [],
"source": [
"struct MyInt {\n",
" MyInt() {}\n",
" MyInt( int x ) : x_(x) {}\n",
" int x_ = 42 ; // default value\n",
"} ;"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"slideshow": {
"slide_type": "fragment"
}
},
"outputs": [],
"source": [
"Int i ;\n",
"Int j(1) ;\n",
"std::cout << i.x_ << std::endl ;\n",
"std::cout << j.x_ << std::endl ;"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"## Preview of the keyword `auto`\n",
"\n",
"Tired of typing those painful iterator types, although what you want is so obvious ? When defining a variable with an initial value, you can now let the C++11 compiler deduce the type : jsut say `auto` instead of the type name. Would you guess how to do it below ?"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"slideshow": {
"slide_type": "fragment"
}
},
"outputs": [],
"source": [
"#include <list>\n",
"#include <map>"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"slideshow": {
"slide_type": "fragment"
}
},
"outputs": [],
"source": [
"std::map<std::vector<int>,std::list<float>> m ;\n",
"A new flavor of `for` enables to process simply all the elements of a collection, provided this collection has methods `begin()` and `end()`. Instead of:"
"In ancient C++, the enumerations let you define constants which are considered as integers. This is both handy and sometimes tricky. Try the code below."