Clang is (draft) C++14 feature-complete!

A few hours ago, Clang completed checkin 194194 to be feature-complete for draft C++14 including both language extensions and standard library features. (Note: The library conformance requires using libc++, instead of libstdc++ which is supported on more platforms but is not as conforming.) Congratulations to the Clang team for this achievement!

With this progress, it appears that the next release of Clang and LLVM, expected in December or January, will be draft C++14 feature-complete. C++14 itself may still undergo final changes at the February 2014 ISO C++ meeting, which is expected to be the final meeting for technical tweaks to the contents of C++14.

Why does C++ not allow multiple types in one auto statement? -- StackOverflow

Recently on SO:

Why does C++ not allow multiple types in one auto statement?

The 2011 C++ standard introduced the new keyword auto, which can be used for defining variables instead of a type, i.e.

auto p=make_pair(1,2.5);                   // pair<int,double>
auto i=std::begin(c), end=std::end(c);     // decltype(std::begin(c))

In the second line, i and end are of the same type, referred to as auto. The standard does not allow

auto i=std::begin(container), e=std::end(container), x=*i;

when x would be of different type. My question: why does the standard not allow this last line? ...

Ode To a Flat Set -- Jon Kalb

Grecian-Urn-187x300.jpegA nice short overview of when you might want your associative container to use a contiguous implementation instead of a tree under the covers:

Ode to a Flat Set

by Jon Kalb

From the article:

The Boost Container library has a family of flat_* containers that have associative container interfaces and semantics, but are implemented as sorted vectors.

In addition to faster lookup, the flat_* containers have much faster iteration, less memory overhead, fewer allocations, and improved cache performance.

However, as with all things, there are trade-offs.

Exception safety: The strong guarantee and move semantics

meyers-gn13.PNGAn interesting question was asked recently on StackOverflow that nicely ties in with Scott Meyers' "Effective C++11/14 Sampler" talk two months ago at GoingNative 2013 and the interestingly named feature std::move_if_noexcept, both referenced in the answers.

Since the gorier details of the answer lie in "watch Scott's talk," we merrily abuse a snapshot of Dr. Meyers during said talk as the highlight graphic for this post.

Exception safe code and move semantics

I want to write container class. This container has insert method that have two specializations -- first uses copy constructors to copy data from one container to another container element wise. If copy constructor throws exception I just undo all changes to the container like nothing happens.

The second specialization uses move constructor and thats the place where things got complicated. When I move items from one container to another container element by element, move constructor can throw exception. If this happens -- I've got really messy state when some elements are moved and other elements stays in it's original places. If I try to move elements back -- I can get another exception.

Is it possible to write something like this in exception safe manner or exception safety and move semantics are mutually exclusive?

Compiling and Linking in C++ -- Rusty Ocean

Selection_101.pngLife'n'gadget just published a nice overview of the basic C++ compilation model, useful for people who are new to programming in C++.

Compiling and Linking in C++

by Rusty Ocean

From the article:

When you write a C++ program, the next step is to compile the program before running it. The compilation is the process which convert the program written in human readable language like C, C++ etc into a machine code, directly understood by the Central Processing Unit. There are many stages involved in creating a executable file from the source file. The stages include Preprocessing, Compiling and Linking in C++...

Duetto: A C++ compiler for the Web going beyond emscripten and node.js

logo_duetto_quadrato_192.pngLearning Technologies Ltd. has released a new Clang-based C++ compiler for the Web:

Duetto: a C++ compiler for the Web going beyond emscripten and node.js

From the announcement:

Today Lean­ing Tech­nolo­gies Ltd. releases duetto, a com­piler designed to develop integrated (back­end and fron­tend) web appli­ca­tions in C++. duetto is now avail­able to the pub­lic as FOSS here, and will be offered in a com­mer­cial pack­age with closed-source-friendly licens­ing soon.

[... duetto] allows to pro­gram both the fron­tend and the back­end of a Web appli­ca­tion in an inte­grated C++ code­base, com­pil­ing them respec­tively to JavaScript and native code.

Duetto com­bines the advan­tages of emscripten and node.js by allow­ing the pro­gram­mer to:

  • write web appli­ca­tions in C++, reusing exist­ing code and mak­ing port­ing of whole appli­ca­tions and games to the browser plausible.
  • code both the fron­tend and the back­end of a web appli­ca­tion in the same lan­guage and codebase
In addi­tion to this, duetto pro­vides some nice features:
  • Bring the robust­ness and proven scal­a­bil­ity of C++ pro­gram­ming to the Web
  • You can access all browser APIs directly. Duetto inher­its the C++ phi­los­o­phy of expos­ing the plat­form capa­bil­i­ties (and lim­i­ta­tions) to the users. There is no mid­dle man.
  • Duetto is based on LLVM/clang. An indus­try stan­dard C++ com­piler is a programmer’s best friend: code san­ity is ver­i­fied as com­pile time, includ­ing RPC signatures.
  • The LLVM tool­chain also guar­an­tees that a mind-blowing set of opti­miza­tions is run at com­pile time, gen­er­at­ing highly effi­cient code. This decreases the bur­den on JavaScript JIT com­piler at runtime.
  • Con­trar­ily to emscripten we do not try to emu­late a tra­di­tional address space using typed arrays, but directly map C++ objects to JS objects. This reduces mem­ory con­sump­tion since the garbage col­lec­tor can delete unused object.

New Adventures in C++ with Cinder and More -- Ale Contenti

The Cinder C++ library for graphics got a shout-out from Herb Sutter at GoingNative'13, and now we get a full hour-long talk about Cinder from Visual Studio's own Ale Contenti.

New Adventures in C++ with Cinder and More

Play and be productive with modern C++, graphics, on-the-fly projects and more! Starting from the latest Going Native 2013 talks as an inspiration, we will explore how easy is to mold ideas into graphics apps with C++ and Cinder, and how simple tools and techniques can help us be more productive in Visual Studio!

Watch the video, or download the slides.

ODB C++ ORM 2.3.0 Released, Adds Schema Evolution Support

ODB is an open source object-relational mapping (ORM) system for C++. It allows you to persist C++ objects to a relational database without having to deal with tables, columns, or SQL and without manually writing any of the mapping code.

Major new features in this release:

  • Support for database schema evolution, including automatic schema migration, immediate and gradual data migration, as well as soft object model changes (ability to work with multiple schema versions using the same C++ classes). For a quick showcase of this functionality see the Changing Persistent Classes section in the Hello World Example chapter.
  • Support for object sections which provide the ability to split data members of a persistent C++ class into independently loaded/updated groups.
  • Support for automatic mapping of C++11 enum classes.

A more detailed discussion of these features can be found on the blog. For the complete list of new features in this version see the official release announcement.

ODB is written in portable C++ (both C++98/03 and C++11 are supported) and you should be able to use it with any modern C++ compiler. In particular, we have tested this release on GNU/Linux (x86/x86-64/ARM), Windows (x86/x86-64), Mac OS X (x86), and Solaris (x86/x86-64/SPARC) with GNU g++ 4.2.x-4.8.x, MS Visual C++ 2005, 2008, 2010, and 2012, Sun Studio 12u2, and Clang 3.x.

The currently supported database systems are MySQL, SQLite, PostgreSQL, Oracle, and SQL Server. ODB also provides optional profiles for Boost and Qt, which allow you to seamlessly use value types, containers, and smart pointers from these libraries in your persistent classes.

More information, documentation, source code, and pre-compiled binaries are available on the project's page.