From me personally:
C ++ 11 did not bring anything really significant to the language. Roughly speaking, just simplified some points. After all, the flexibility of C ++ allows you to do everything (almost everything: not vacuuming). But nevertheless, agree it is pleasant, when one of the not the easiest programming languages becomes more accessible for understanding, easier for perception, more convenient for work.
Text translation under the cut. Posted by John D. Cook.
The new standard C ++ (that is, C ++ 11) contains some Python'o-like functions that I have come across lately. This article will talk directly about for-loops and raw strings.
In Python, you can go through the list without any loop counter. For example:
for p in [2, 3, 5, 7, 11]: print p
Something similar can be used in C ++ 11:
int primes[5] = {2, 3, 5, 7, 11}; for (int &p : primes) cout << p << "\n";
Python also has a raw string. If you add the letter R in front of the string, the string is interpreted character by character. For example, the code:
print "Hello\nworld"
Will give the following result:
Hello
world
')
But:
print R"Hello\nworld"
Displays:
Hello \ nworldBecause \ n is not perceived as a newline character, but simply displayed as two separate characters.
In C ++ 11, raw string is used in the same way, but also requires a delimiter inside quotes:
cout << R"(Hello\nworld)";
The syntax of raw string in C ++ 11 is slightly more difficult to read than that of its Python counterpart. The advantage, however, is that such strings may contain double quotes, in and of themselves they do not terminate the string. For example:
cout << R"(Hello "world")";
Displays:
Hello "world"In Python, this is not necessary, since single and double quotes are interchangeable. To get double quotes inside a string, you need to use single quotes outside and vice versa. Also note that the raw string in C ++ 11 requires a capital letter R, unlike Python, in which you can use both large and small.
C ++ 11 functions are supported by gcc 4.6.0. The MinGW version of gcc for Windows can be downloaded
here . To use C ++ 11 functions, you must add the following parameter to the command line
-std = c ++ 0x .
For example:
g ++ -std = c ++ 0x hello.cppVisual Studio 2010 supports many new features of C ++ 11, but, alas, they are not described here.