Important semantic effects of small syntax errors -- Matt Wilson
Every C++ programmer should see a bug like this, from Matthew Wilson's post. As a warning.
Important semantic effects of small syntax errors
by Matt Wilson
October 25, Pavia, Italy
November 6-8, Berlin, Germany
November 3-8, Kona, HI, USA
By Andrzej Krzemienski | May 18, 2017 07:34 AM | Tags: basics
Every C++ programmer should see a bug like this, from Matthew Wilson's post. As a warning.
Important semantic effects of small syntax errors
by Matt Wilson
By Meeting C++ | May 10, 2017 03:09 AM | Tags: conferences community basics
An update on the ongoing call for talks for Meeting C++ 2017:
Reaching out for new speakers at Meeting C++ 2017
by Jens Weller
From the article:
Maybe you can help in an ongoing effort for the C++ Community...
There is an ongoing effort, to ensure that everyone feels welcome at our C++ events...
By Adrien Hamelin | May 4, 2017 01:05 PM | Tags: c++11 basics
Quick A: No.
Recently on SO:
Is there a way to mark a parent's virtual function final from a child class without reimplementing it
No, you can't do it without reimplementing it. So just reimplement it:
struct Child : public Parent { virtual void fn() override final { Parent::fn(); } };N.B. saying
virtual ... override finalis entirely redundant,finalis an error on a non-virtual function, so you should just say:void fn() final { Parent::fn(); }See http://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#Rh-override
By Adrien Hamelin | May 2, 2017 01:47 PM | Tags: c++11 basics
Quick A: Are equivalent, but shrink_to_fit mark the intention.
Recently on SO:
shrink_to_fit() vs swap trick
The swap trick isn't actually constant-time. The cost of performing the actual swap is indeed O(1), but then there's the cost of the
std::vectordestructor firing and cleaning up all the allocated space. That can potentially have cost Ω(n) if the underlying objects have nontrivial destructors, since thestd::vectorneeds to go and invoke those destructors. There's also the cost of invoking the copy constructors for all the elements stored in the initial vector, which is similarly Ω(n).As a result, both approaches should have roughly the same complexity, except that
shrink_to_fitmore clearly telegraphs the intention and is probably more amenable to compiler optimizations.
By Adrien Hamelin | Apr 24, 2017 12:43 PM | Tags: c++11 basics
Quick A: The signature of the function is first.
Recently on SO:
Syntax of final, override, const with trailing return types
The correct syntax should be:
- override and final should appear after the member function declaration, which including the trailing return type specification, i.e.
auto debug(ostream& os=cout) const ->ostream& override final;
- override and final should not be used with the member function definition outside the class definition, so just remove them:
auto Derived::debug(ostream& os) const ->ostream& { os << "dval: " << dval << endl; return os; }
By Jonas Devlieghere | Apr 19, 2017 12:04 AM | Tags: c++11 basics
Storing unique pointers in containers is great, but how do you design an API around it?
Exposing Containers of Unique Pointers
by Jonas Devlieghere
From the article:
There's probably no reason to expose to the caller that objects are stored as unique pointers.
By Adrien Hamelin | Apr 14, 2017 01:03 AM | Tags: community basics
Quick A: No
Recently on SO:
Are the experimental features of modern C++ reliable for long-term projects?
Is it guaranteed that all compliant compilers have the same experimental features?No, experimental features are optional.Are experimental features prone to big changes that make them unreliable?Yes, the C++ committee might even decide to abandon a feature or in the process of standardization a defect might come up that would force a feature to change.Generally, it's not a good idea to depend on experimental features. Experimental features are exactly what the word says (i.e., to experiment with).
By Jason Turner | Mar 14, 2017 04:40 PM | Tags: embedded c++14 basics
Episode 54 of C++ Weekly.
Zero Cost Embedded C++: Part 1
by Jason Turner
About the show:
This episode of C++ Weekly asks if it's possible to use the latest C++ features on an embedded device with only 2KiB of storage and 128 bytes of RAM.
By Adrien Hamelin | Mar 13, 2017 12:43 PM | Tags: c++11 basics
Do you use it?
C++ Braced Initialization
by Edouard of quasardb
From the article:
Since C++ 11 it's possible to use braces for construction and initialization. Although this is something you could ignore for the code you write, it's obviously important to know for the code you may read.
If you have a couple of years of experience in C++, the temptation can be great to keep your old habits because "All these new features are useless! The language is bloated! Those people in the committee!".
Let's make sense out of the bloat...
By Meeting C++ | Mar 2, 2017 07:09 AM | Tags: reflection intermediate experimental c++20 basics advanced
Since the overview on the current papers for Kona, I wanted to know more about reflection...
Reflections on the reflection proposals
by Jens Weller
From the article
A few weeks ago I wrote a short overview over the most interesting papers for the current C++ Committee meeting in Kona, Hawaii. The big surprise was that there were many papers on reflection, while there already is a very detailed proposal for reflection.
With the C++ committee currently in Kona discussing lots of proposals, there will be some changes to the on going effort for reflection, but the current proposals are detailed enough to give an overview.