Range Comprehensions -- Eric Niebler

Do you "comprehend" ranges? From a key participant in some of the latest discussion about ranges for C++:

Range Comprehensions

by Eric Niebler

From the article:

I’ve been busy since I last wrote about ranges. I have a lot of news to share, but in this post, I’m going to narrowly focus on a recent development that has me very excited. It’s a new feature that I’m calling range comprehensions, and they promise to greatly simplify the business of creating custom ranges...

noexcept: what for? -- Andrzej KrzemieĊ„ski

From the desk of Andrzej:

noexcept -- what for?

by Andrzej Krzemieński

From the article:

In this post I would like to share my observation on where using noexcept really adds value. It is less often than what one might expect, and it does not have that much to do with throwing or not throwing exceptions. The conclusion surprises me a bit, and I hesitate to present it because it is counter to the advice I hear from people I consider authorities on the subject...

Async-Await in C++ -- Paolo Severini

severini-await.PNGParis, April 2014: Paolo Severini explores the Async-Await pattern and the related proposal for C++17, showing also an example by using Visual Studio 2013 November CTP.

Async-Await in C++

by Paolo Severini

From the article:

... what about native [C++] programming? Is there anything like async/await that we can use with our futures? We can find the answer in N3858, another proposal made by Gustafsson et al. for C++17.

This time the changes proposed are to the language itself and not just to the library. The idea is to introduce the equivalent of C# async methods in the form of resumable functions. They can be thought as the basis to add to C++ the support for real co-routines, and are not strictly related to the <future> library, even though they have being defined especially to improve the usability of futures and promises...

Announcing the student program for Meeting C++ 2014

Today I have the honor to announce the details of this years student program for Meeting C++ 2014

Meeting C++ 2014: the student program

by Jens Weller

From the article:

The Meeting C++ Student program will enable 50 students to attend Meeting C++ 2014 plus 3 exclusive workshops organized by think-cell one day before the conference on December 4th. So, for students this will be a 3 day conference! After the workshops you will be invited to the student dinner by think-cell.

Writing a simple bar graph widget in Qt

Recently I had to implement a simple version of a bar graph widget in Qt:

Writing a bar graph widget in Qt

by Jens Weller

From the Article:

Today I had a little fun with Qt and wrote a widget for displaying a bar graph. I have two different situations where I need the bar graph in my back end: displaying the votes a single talk got, and displaying one big bar graph of all the talks.

Preferring STL algorithms from algorithm and numeric -- makramkd

(Related note: If you haven't yet watched and grokked Sean Parent's wonderful C++ Seasoning talk from last fall's GoingNative conference, do yourself a favor and watch it. You will find it eye-opening. If you have already watched it, you might still find it worth a re-watch to fully absorb.)

Here's a nice case study of why not to roll your own algorithms, when C++ comes with a treasure chest full of pre-written, pre-debugged, and pre-optimized (in a good way) standard algorithms in the box:

Preferring STL algorithms from algorithm and numeric

by makramkd

From the article:

This post isn’t meant to be a documentation of the algorithm and numeric headers: you can find those readily at cppreference. In this post I’m going to try to convince people that write very similar algorithms to those in the standard library to not use these algorithms in production code, and to prefer ones from the STL.

Let’s get the show on the road. I’m going to start with the most simple one, because I just want to get my point across.

Programming Conversations Lecture Series -- Alexander Stepanov

alex-stepanov-programming-conversations.PNGYet again the wonderful ongoing video series from Alexander Stepanov and Paramjit Oberoi (A9 Organization):

Programming Conversations

Programming conversations is intended as an interactive course on programming. We'll try to practice the Socratic method: eventually there will be very little lecturing, and most of the time will be spent in discussions and in writing code together. We plan to cover a wide variety of topics, starting with the nature of programming, and continuing, in no particular order, with benchmarking, algorithms, data structures, caches, instruction level parallelism, generic programming, variable sized types, and Platonic ideas.

Most of the concepts are explained in terms of C++11/STL/Boost.

Source code is available.

 

 

 

 

GCC 4.9.0 released, full of improved C++11 and C++14 features

GCC 4.9.0 is now available, with further improved C++11 and C++14 conformance.

GCC 4.9.0 Released

by Jakub Jelinek

From the announcement:

Support for various C++14 additions have been added to the C++ Front End, on the standard C++ library side the most important addition is support for the C++11 <regex>. ...

Various kinds of undefined behaviors in programs can be now diagnosed at runtime through Undefined Behavior Sanitizer. ...

See http://gcc.gnu.org/gcc-4.9/changes.html for more information about changes in GCC 4.9.

From the Changes page:

The G++ implementation of C++1y return type deduction for normal functions has been updated to conform to N3638, the proposal accepted into the working paper. Most notably, it adds decltype(auto) for getting decltype semantics rather than the template argument deduction semantics of plain auto:

int& f();
         auto  i1 = f(); // int
decltype(auto) i2 = f(); // int&
G++ supports C++1y lambda capture initializers:
[x = 42]{ ... };
Actually, they have been accepted since GCC 4.5, but now the compiler doesn't warn about them with -std=c++1y, and supports parenthesized and brace-enclosed initializers as well.
G++ supports C++1y variable length arrays. G++ has supported GNU/C99-style VLAs for a long time, but now additionally supports initializers and lambda capture by reference. In C++1y mode G++ will complain about VLA uses that are not permitted by the draft standard, such as forming a pointer to VLA type or applying sizeof to a VLA variable. Note that it now appears that VLAs will not be part of C++14, but will be part of a separate document and then perhaps C++17.
void f(int n) {
  int a[n] = { 1, 2, 3 }; // throws std::bad_array_length if n < 3
  [&a]{ for (int i : a) { cout << i << endl; } }();
  &a; // error, taking address of VLA
}
G++ supports the C++1y [[deprecated]] attribute modulo bugs in the underlying [[gnu::deprecated]] attribute. Classes and functions can be marked deprecated and a diagnostic message added:
class A;
int bar(int n);
#if __cplusplus > 201103
class [[deprecated("A is deprecated in C++14; Use B instead")]] A;
[[deprecated("bar is unsafe; use foo() instead")]]
int bar(int n);

int foo(int n);
class B;
#endif
A aa; // warning: 'A' is deprecated : A is deprecated in C++14; Use B instead
int j = bar(2); // warning: 'int bar(int)' is deprecated : bar is unsafe; use foo() instead

G++ supports C++1y digit separators. Long numeric literals can be subdivided with a single quote ' to enhance readability:

int i = 1048576;
int j = 1'048'576;
int k =0x10'0000;
int m = 0'004'000'000;
int n = 0b0001'0000'0000'0000'0000'0000;
double x = 1.602'176'565e-19;
double y = 1.602'176'565e-1'9;
G++ supports C++1y polymorphic lambdas.
// a functional object that will increment any type
auto incr = [](auto x) { return x++; };

Runtime Library (libstdc++)

Improved support for C++11, including:

  • support for <regex>;
  • The associative containers in <map> and <set> and the unordered associative containers in <unordered_map> and <unordered_set> meet the allocator-aware container requirements;

Improved experimental support for the upcoming ISO C++ standard, C++14, including:

  • fixing constexpr member functions without const;
  • implementation of the std::exchange() utility function;
  • addressing tuples by type;
  • implemention of std::make_unique;
  • implemention of std::shared_lock;
  • making std::result_of SFINAE-friendly;
  • adding operator() to integral_constant;
  • adding user-defined literals for standard library types std::basic_string, std::chrono::duration, and std::complex;
  • adding two range overloads to non-modifying sequence oprations std::equal and std::mismatch;
  • adding IO manipulators for quoted strings;
  • adding constexpr members to <utility>, <complex>, <chrono>, and some containers;
  • adding compile-time std::integer_sequence;
  • adding cleaner transformation traits;
  • making <functional>s operator functors easier to use and more generic;

An implementation of std::experimental::optional.

An implementation of std::experimental::string_view.

The non-standard function std::copy_exception has been deprecated and will be removed in a future version. std::make_exception_ptr should be used instead.