basics

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.

CS 251: Intermediate Software Design in C++ -- Doug Schmidt

Doug Schmidt's C++-based software design course is available on YouTube.:

CS 251: Intermediate Software Design in C++

by Douglas Schmidt

This video playlist contains screencasts from a course I'm teaching on advanced C++ and object-oriented patterns/frameworks in the Spring of 2014 at Vanderbilt University. Please see http://www.dre.vanderbilt.edu/~schmidt/cs251/ for more information on this course.

Topics covered include:

  • Overview of C++ (3 lectures)
  • Overview of Subversion
  • Overview of the STL (8 lectures)
  • Overview of Patterns (2 lectures)
  • A Case Study of "Gang-of-Four" Patterns (8 lectures)

About the instructor:

Douglas C. Schmidt is a Professor of Computer Science, Associate Chair of the Computer Science and Engineering program, and a Senior Researcher at the Institute for Software Integrated Systems, all at Vanderbilt University. He has also been the Chief Technology Officer for the Software Engineering Institute at Carnegie Mellon University, where he was responsible for directing the technical vision and strategic R&D investments.

C++ developers will know of Doug particularly because of his widely-acclaimed ACE and related libraries.

Understanding the New Set and Map Containers in the C++11 Standard Library -- S Clamage and D Gove

On the Oracle Tech Network, a nice reminder of the still-"new"-to-some hash-based containers, co-authored by the chair of the U.S. C++ standards committee:

Understanding the New Set and Map Containers in the C++11 Standard Library

by Steve Clamage and Darryl Gove

From the article:

One of the areas in the new C++ standard that has seen the most enhancement is the Standard Library. The functionality that is most likely to be immediately useful to developers is the additions to the container classes. This article describes the new set and map containers.

Quick Q: Why does this function take a parameter by value? -- StackOverflow

A classic on SO:

Why do we copy then move?

I saw code somewhere in which someone decided to copy an object and subsequently move it to a data member of a class. This left me in confusion in that I thought the whole point of moving was to avoid copying. Here is the example:

struct S
{
    S(std::string str) : data(std::move(str))
    {}
};

Here are my questions:

  • Why aren't we taking an rvalue-reference to str?
  • Won't a copy be expensive, especially given something like std::string?
  • What would be the reason for the author to decide to make a copy then a move?
  • When should I do this myself?