basics

Ref-qualified member functions -- Alexander Kulikov

kukuruku.PNGToday on Kukuruku:

Ref-qualified member functions

by Alexander Kulikov

From the article:

Today I’m going to tell you about a new and a little known (to my mind) C++ feature — reference-qualified member functions. I’ll tell about the rules of such functions overloading and, as an example of use, I’ll show you that with the help of ref-qualified you can try to improve the resource management scheme, which is implemented with the help of another C++ idiom — RAII.

Quick Q: Why can't a data member be in a lamba capture list -- StackOverflow

Quick A: Because you can only capture local (stack) objects, including function parameters, and to access a data member in a member function you capture the local variable this.

Today on SO:

Why can't a data member be in a lamba capture list

I have a class foo that has bar as a member variable.

In another member function of the class, I'm writing a lambda function:

[bar](void){}

But I can't include bar in the capture list. Why is that?

Quick Q: How do generic lambdas work? -- StackOverflow

Quick A: They generate a templated operator(), and that means you can call the same closure object with all sorts of different parameters and it just stamps out the function for each set of parameter types.

A "new classic" question on SO, classic because it was posted a year ago, but newly relevant because now the mainstream compilers are implementing the feature:

How does generic lambda work in C++14?

How does generic lambda work (auto keyword as argument type)?

Is it similar to templates where for each different argument type compiler generates functions with the same body but changed types or is it more similar to Java's generics?

Code example:

auto glambda = [](auto a) { return a; };

Preface to Programming: Principles and Practice Using C++, 2nd Edition -- Bjarne Stroustrup

programming-2e.jpgStroustrup's introduction to programming book has now been updated for modern C++. The Preface was posted on InformIT:

Preface to Bjarne Stroustrup's Programming: Principles and Practice Using C++, 2nd Edition

by Bjarne Stroustrup

From the preface:

This book is for someone who has never programmed before but is willing to work hard to learn. It helps you understand the principles and acquire the practical skills of programming using the C++ programming language. My aim is for you to gain sufficient knowledge and experience to perform simple useful programming tasks using the best up-to-date techniques. How long will that take? As part of a first-year university course, you can work through this book in a semester...

C++ User Group Meetings in May

Again, a list of user group meetings for this month. In total its going to be 16 user groups meeting this month:

C++ User Group Meetings in May 2014

by Jens Weller

From the Article:

The Meetings

    8th May C++ UG Aachen - SIMD Programmierung
    8th May C++ UG Belgium
        Parallelism in the C++ Standard, what to expect from C++17
        Asynchronous Programming with futures and await
    8th May C++ UG Dresden - C++ Memory Model
    8th May C++ UG New York - Whats next for C++
    13th May C++ UG Philadelphia - Profiling and Perfomance
    14th May C++ UG San Francisco/Bay area
    15th May C++ UG Malmö/Sweden - Battle of the build systems
    19th May C++ UG Denver - CppNow, Eclipse Configuration, Qt Creator and more...
    20th May C++ UG Berlin - C++ in the demo scene
    21st May C++ UG Düsseldorf - Expression Templates
    21st May C++ UG Hamburg
    21st May C++ UG Seattle/Northwest - Agile Architecture
    23rd May C++ UG Paris
        Introspection et reflection en C++
        Le SIMD en pratique avec boost SIMD
        Clang & C++
    27th May C++ UG Chicago
    28th May C++ UG Heidelberg
    28th May C++ UG San Francisco/Bayarea - C++Now tripreport

Qt & JSON

Recently I could play around with Qt5 JSON API:

Qt & JSON

by Jens Weller

From the Article:

With Qt5 there is a new API for reading and writing JSON files in Qt. In the last days I had the chance to play around with this API, as I implemented importing and exporting different data sets from and to JSON.

Quick Q: Are class member initializers evaluated at compile time? -- StackOverflow

Quick A: Maybe.

Recently on SO:

Does in class member initialization takes place at compile time or run-time?

In C++11 a new feature was introduced where the programmer can initialize class member variables inside class's definition, see code below:

struct foo
{
  int size = 3;
  int id   = 1;
  int type = 2;
  unsigned char data[3] = {'1', '2', '3'};
};

Is this initialization takes place during compile time or this feature is just syntactic sugar and member variables are initialized in the default constructor?

Nugget: Context-sensitive keywords -- Tony DaSilva

Recently on Bulldozer00:

Context Sensitive Keywords

by Tony DaSilva

From the article:

With the seriousness of keyword introduction in mind, one might wonder why the override and final keywords were added to C++11. Surely, they’re so common that millions of lines of C/C++ legacy code will get broken. D’oh!

But wait! To severely limit code-breakage, the override and final keywords are defined to be context sensitive...

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.