basics

Lightning Talks from Meeting C++ 2019 are now online!

The lightning talks from Meeting C++ 2019 are now online!

Meeting C++ Youtube Channel

by Jens Weller

From the article:

A few lightning talks I'd like to point to:

Finding hard to find bugs with Address Sanitizer - Marshall Clow

Consistently Inconsistent - Conor Hoekstra

Why don't the cool kids like OOP? - Jon Kalb

How to initialize x from expression y - Howard Hinnant

5 Ways Using Braces Can Make Your C++ Code More Expressive--Jonathan Boccara

The power of the brace.

5 Ways Using Braces Can Make Your C++ Code More Expressive

by Jonathan Boccara

From the article:

A lot of languages use braces to structure code. But in C++, braces are much more than mortar for holding blocks of code together. In C++, braces have meaning.

Or more exactly, braces have several meanings. Here are 5 simple ways you can benefit from them to make your code more expressive...

Highlighting the Student and Support Tickets for Meeting C++ 2019

Also available in this year: the programs for students and diversity & support for Meeting C++ 2019

Highlighting the Student and Support Tickets for Meeting C++ 2019

by Jens Weller

From the article:

With the Schedule for Meeting C++ 2019 being complete regarding submitted talks, I want to highlight, that there is an opportunity for folks to attend the conference with a free ticket!

Quick Q: Removing item from vector, while in C++11 range 'for' loop?

Quick A: it is not possible

Recently on SO:

Removing item from vector, while in C++11 range 'for' loop?

No, you can't. Range-based for is for when you need to access each element of a container once.

You should use the normal for loop or one of its cousins if you need to modify the container as you go along, access an element more than once, or otherwise iterate in a non-linear fashion through the container.

For example:

auto i = std::begin(inv);

while (i != std::end(inv)) {
    // Do some stuff
    if (blah)
        i = inv.erase(i);
    else
        ++i;
}

Quick Q: How do C++ class members get initialized if I don't do it explicitly?

Quick A: default constructors are called if available, otherwise there is no initialisation.

Recently on SO:

How do C++ class members get initialized if I don't do it explicitly?

In lieu of explicit initialization, initialization of members in classes works identically to initialization of local variables in functions.

For objects, their default constructor is called. For example, for std::string, the default constructor sets it to an empty string. If the object's class does not have a default constructor, it will be a compile error if you do not explicitly initialize it.

For primitive types (pointers, ints, etc), they are not initialized -- they contain whatever arbitrary junk happened to be at that memory location previously.

For references (e.g. std::string&), it is illegal not to initialize them, and your compiler will complain and refuse to compile such code. References must always be initialized.

So, in your specific case, if they are not explicitly initialized:

    int *ptr;  // Contains junk
    string name;  // Empty string
    string *pname;  // Contains junk
    string &rname;  // Compile error
    const string &crname;  // Compile error
    int age;  // Contains junk

Quick Q: What are copy elision and return value optimization?

Quick A: optimisation compilers are allowed to do for perfomance.

Recently on SO:

What are copy elision and return value optimization?

Copy elision is an optimization implemented by most compilers to prevent extra (potentially expensive) copies in certain situations. It makes returning by value or pass-by-value feasible in practice (restrictions apply).

It's the only form of optimization that elides (ha!) the as-if rule - copy elision can be applied even if copying/moving the object has side-effects...

Quick Q: Does the default constructor initialize built-in types?

Quick A: No.

Recently on SO:

Does the default constructor initialize built-in types?

Implicitly defined (by the compiler) default constructor of a class does not initialize members of built-in types.

However, you have to keep in mind that in some cases the initialization of a instance of the class can be performed by other means. Not by default constructor, nor by constructor at all...

Submit your talk to Meeting C++ 2019!

The call for submissions is open for Meeting C++ 2019!

New speakers are welcome to submit as there is a dedicated track for this, start speaking at Meeting C++!

Submit your talk to Meeting C++ 2019!

by Jens Weller

From the article:

When Meeting C++ 2019 was announced in the begin of April, there was already a hint that you could submit your talks. And so far a few have done so. Now its time for an official news entry. Submit your talk to Meeting C++ 2019! This year its the 8th edition of Meeting C++!

Speaking at Meeting C++ is a fun experience, you get to attend the speakers dinner, attend the full conference for free and enjoy the luxurious Hotelrooms the Andels offers from Wednesday to Saturday! You can look at last years schedule to get a feel for what your competition might talk about, but have in mind that you don't see the talks that were not submitted! If you want to talk about a C++ topic that wasn't covered yet, or have a unique idea for your talk, please submit! Speakers don't need to buy a ticket and the conference has a contingent of rooms available for speakers & staff.