How to Learn More About C++0X

Where can I learn more about C++0x?

Articles on

Lambda Expressions,

The Type Traits Library,

The rvalue Reference,

Concepts,

Variadic Templates,

shared_ptr

Regular Expressions

Tuples

Multi Threading

General Discussion

The C/C++ Users Journal,

The New C++,

Article

Videos

Google tech talk

overview of various features

overview at wikipedia

Library

Boost

What do numbers using 0x notation mean?

Literals that start with 0x are hexadecimal integers. (base 16)

The number 0x6400 is 25600.

6 * 16^3 + 4 * 16^2 = 25600

For an example including letters (also used in hexadecimal notation where A = 10, B = 11 ... F = 15)

The number 0x6BF0 is 27632.

6 * 16^3 + 11 * 16^2 + 15 * 16^1 = 27632
24576 + 2816 + 240 = 27632

C++0X when?

UPDATE : years later...

The last Draft have been officially finalized few weeks ago, in Mars 2011 and will be officially out around July 2011. The name of the new standard would be C++2011 : http://herbsutter.com/2011/03/25/we-have-fdis-trip-report-march-2011-c-standards-meeting/

Microsoft C++ compiler (VC10) provide C++0x features (lambda, decltype, auto, r-value reference and nullptr). GCC provide a work in progress version that already implements a lot of features (see http://gcc.gnu.org/projects/cxx0x.html).
Comeau C++ seems to be more advanced. CLang started to provide some features but not much for the moment (see http://clang.llvm.org/cxx_status.html )

So, most of the features are be availables for the main c++ compilers at the time the ISO administration officially validate the draft. Some advanced features are still not be available before some years I guess.

Why are hexadecimal numbers prefixed with 0x?

Short story: The 0 tells the parser it's dealing with a constant (and not an identifier/reserved word). Something is still needed to specify the number base: the x is an arbitrary choice.

Long story: In the 60's, the prevalent programming number systems were decimal and octal — mainframes had 12, 24 or 36 bits per byte, which is nicely divisible by 3 = log2(8).

The BCPL language used the syntax 8 1234 for octal numbers. When Ken Thompson created B from BCPL, he used the 0 prefix instead. This is great because

  1. an integer constant now always consists of a single token,
  2. the parser can still tell right away it's got a constant,
  3. the parser can immediately tell the base (0 is the same in both bases),
  4. it's mathematically sane (00005 == 05), and
  5. no precious special characters are needed (as in #123).

When C was created from B, the need for hexadecimal numbers arose (the PDP-11 had 16-bit words) and all of the points above were still valid. Since octals were still needed for other machines, 0x was arbitrarily chosen (00 was probably ruled out as awkward).

C# is a descendant of C, so it inherits the syntax.

What new Unicode functions are there in C++0x?

Does the new library provide standard methods to convert UTF-8 to UTF-16, etc.?
No. The new library does provide std::codecvt facets which do the conversion for you when dealing with iostream, however. ISO/IEC TR 19769:2004, the C Unicode Technical Report, is included almost verbatim in the new standard.

Does the new library allowing writing UTF-8 to files, to the console (or from files, from the console). If so, can we use cout or will we need something else?
Yes, you'd just imbue cout with the correct codecvt facet. Note however that the console is not required to display those characters correctly

Does the new library include "basic" functionality such as: discovering the byte count and length of a UTF-8 string, converting to upper-case/lower-case(does this consider the influence of locales?)
AFAIK that functionality exists with the existing C++03 standard. std::toupper and std::towupper of course function just as in previous versions of the standard. There aren't any new functions which specifically operate on unicode for this.

If you need these kinds of things, you're still going to have to rely on an external library -- the <iostream> is the primary piece that was retrofitted.

What, specifically, is added for unicode in the new standard?

  • Unicode literals, via u8"", u"", and U""
  • std::char_traits classes for UTF-8, UTF-16, and UTF-32
  • mbrtoc16, c16rtomb, mbrtoc32, and c32rtomb from ISO/IEC TR 19769:2004
  • std::codecvt facets for the locale library
  • The std::wstring_convert class template (which uses the codecvt mechanism for code set conversions)
  • The std::wbuffer_convert, which does the same as wstring_convert except for raw arrays, not strings.

What is the difference between C++0x and C++11?

C++ and C Standards are usually named after the year they are published in, which makes it easier to remember by.

For example, in C++, the original Standard was published in 1998, so we talk about C++98, and when we refer to its first correction, published in 2003, we talk about C++03.

It had been purported that the next Standard after would be done for 2008, but since it was uncertain, it was dubbed C++0x, where the x stood for either 8 or 9. In practice though, as we all know, the planning shifted and so we end-up with C++11.

Still, for the next version (C++1x), Bjarne Stroustrup stated his intent to do it in 5 years (so about 2016). For now, there are changes envisionned to the core language (concepts, modules and garbage collection), and the focus seems to be more on extending the library (filesystem for example), but it's still early so who knows!

Any good C++0x overviews?

The best two I know of are the Wikipedia page and Stroustrup's FAQ.

I really wouldn't recommend reading the standard until you know what you're looking for. Besides being significantly larger than the C++03 standard, the organization and clarity has gotten somewhat worse in parts.

If you're only going to do one lecture on "advanced C++", you might focus on C++0x features which were adopted from other common sources, such as boost::smart_ptr and std::tr1::unordered_map. Such things are ahead of the curve on adoption.

To use or not to use C++0x features

I'd make the decision on a per-feature basis.

Remember that the standard is really close to completion. All that is left is voting, bugfixing and more voting.

So a simple feature like auto is not going to go away, or have its semantics changed. So why not use it.

Lambdas are complex enough that they might have their wording changed and the semantics in a few corner cases fixed up a bit, but on the whole, they're going to behave the way they do today (although VS2010 has a few bugs about the scope of captured variables, MS has stated that they are bugs, and as such may be fixed outside of a major product release).

If you want to play it safe, stay away from lambdas. Otherwise, use them where they're convenient, but avoid the super tricky cases, or just be ready to inspect your lambda usage when the standard is finalized.

Most features can be categorized like this, they're either so simple and stable that their implementation in GCC/MSVC are exactly how they're going to work in the final standard, or they're tricky enough that they might get a few bugfixes applied, and so they can be used today, but you run the risk of running into a few rough edges in certain border cases.

It does sound silly to avoid C++0x feature solely because they're not formalized yet. Avoid the features that you don't trust to be complete, bug-free and stable, but use the rest.

C++0x will no longer have concepts. Opinions? How will this affect you?

Personally I'm not too unhappy of the removal as the purpose of concepts were to mainly improve compile time error messages, as Jeremy Siek, one of the co-authors of the Concepts proposal, writes (http://lambda-the-ultimate.org/node/3518#comment-50071):

While the Concepts proposal was not
perfect (can any extension to C++
really ever be perfect?), it would
have provided a very usable and
helpful extension to the language, an
extension that would drastically
reduce the infamous error messages
that current users of template
libraries are plagued with.

Of course concepts had more purpose than just enable the compilers to give shorter error messages, but currently I think we all can live without them.

EDIT: Herb Sutter also writes on his blog:

Q: Wasn’t this C++0x’s one big
feature?

A: No. Concepts would be great, but
for most users, the presence or
absence of concepts will make no
difference to their experience with
C++0x except for quality of error
messages.

Q: Aren’t concepts about adding major
new expressive power to the language,
and so enable major new kinds of
programs or programming styles?

A: Not really. Concepts are almost
entirely about getting better error
messages.



Related Topics



Leave a reply



Submit