Daily C++11: How to write move constructors

When I passed to the next matter regarding C++11 in my series, I realized that I didn’t give an example on how to write move constructors in the real world. For anyone who works actively with C++11 it’s obvious, but for people like me that want to find out about the new standard, it would be instrumental to actually see some example. I hope it’ll be clear enough: Continue reading

Posted in Technology | Tagged , , , | Leave a comment

Daily C++11: Constexpr – generalized const expressions and updated PODs definition

A new feature of C++11 is to mark certain functions as constant expressions. For example, if one writes some functions like: Continue reading

Posted in Technology | Tagged , , | Leave a comment

Daily C++11: Rvalue references and move constructors

Probably one of the most important reasons that makes C programmers run away from C++ is the gross inefficiency of having temporaries. The problem was that the language encouraged unnecessary copies; someone who wanted to keep performance as a priority would have avoided code like: Continue reading

Posted in Technology | Tagged , , , | 2 Comments

Daily C++: Ranged for loops

Another fun feature of the new C++11 standard is the ranged for loops; again, a convenience that would make the writing of code a bit easier. It was one feature I seen and liked a lot in other languages; it makes the code a lot easier, in a pleasant way. Continue reading

Posted in Technology | Tagged , , | Leave a comment

Daily C++: Automatic variable types (auto type inference)

One of the nicest improvements when it comes to productivity is the introduction of the new meaning for the auto keyword. This is no different from the var of C#, makes code easier to write, yet sometimes slightly harder to understand. Continue reading

Posted in Technology | Tagged , , | Leave a comment

Daily C++: More on raw string literals

Yesterday’s episode had info on the raw string literals, or, on plain english, how you can write the more complicated strings, that require strange escaping. This was done by using the R prefix, followed by quotes and an open parenthesis; the closing was done by closing the parenthesis and the quotes. Continue reading

Posted in Technology | Tagged , , | Leave a comment

Daily C++11: Raw string literals

Ever wondered how many backslashes are in “\\\\\\\\”? Me too, because that’s how you have to write a regular expression to correspond to two backslashes. And I am bad at counting especially after 10 hours of work, with my head stuck in the monitor. Continue reading

Posted in Technology | Tagged , , | Leave a comment

Daily C++11: More Unicode support

In yesterday’s episode we talked about the new Unicode support for string literals; the standard library has also been extended to support the new encodings: Continue reading

Posted in Technology | Tagged , , | 2 Comments

Daily C++11: String literals

As part of the heritage of the C++ programming language, all string literals were ANSI characters. For wide characters, C++03 defined the L prefix for the string: therefore L”abcd” would represent all the characters including the string terminator in the ambiguous type wchar_t. Unfortunately, the standard never defined limits the form of this character, as a consequence, different implementations use different sizes: 16 and 32 bits being the natural choices.

C++11 rectifies this, Continue reading

Posted in Technology | Tagged , , | Leave a comment

Daily C++11: introduction, nullptr, template closing characters

C++11 is really a step forward in the history of my second favorite programming language (after C, of course). From 1998 there wasn’t much evolution in the language; not that a language needs evolution as a constant, but for sure, but C++ is far from perfect. Continue reading

Posted in Technology | Tagged , , | Leave a comment