C++ Weekly Episode 76: static_print—Jason Turner
Episode 76 of C++ Weekly.
static_print
by Jason Turner
About the show:
In this episode Jason explores an experimental patch to gcc that allows for compile-time printing.
March 19-21, Madrid, Spain
April 1-4, Bristol, UK
June 16-21, Sofia, Bulgaria
By Jason Turner | Aug 14, 2017 08:25 AM | Tags: intermediate experimental
Episode 76 of C++ Weekly.
static_print
by Jason Turner
About the show:
In this episode Jason explores an experimental patch to gcc that allows for compile-time printing.
By Adrien Hamelin | Aug 11, 2017 03:24 PM | Tags: intermediate community
Interested?
Live Webinar agenda and demo project: Refactoring C++ code
by Anastasia Kazakova
From the article:
The webinar about refactoring C++ code is planned for August. Arne Mertz, the author of popular Simplify C++ blog, will talk about general strategies and effective refactoring process.
By Adrien Hamelin | Aug 10, 2017 01:28 PM | Tags: intermediate c++11
Quick A: Because it is defined at compile time in a special section.
Recently on SO:
A little confused about constexpr functions
If 'x' is declared static, there are no errors. Why?This is because there is always exactly one x in the program. It has an address (somewhere in the .data segment under normal conditions).
Confusingly, both static and extern keywords specify the storage duration as static (they differ in linkage)
How is it possible to get a variable address during the compilation process? Aren't they allocated at run-time?Variables with automatic, dynamic or thread storage durations are allocated at runtime. Static duration variables are allocated by the compiler. (The linker and OS can change the location, but they know how to fix all the references when they do)
By Meeting C++ | Aug 10, 2017 08:12 AM | Tags: performance intermediate efficiency community codereview c++14 c++11 basics
Participate in the first two reviews at r/cpp_review:
The reviews have begun
by Jens Weller
From the article
A few weeks ago I announced a C++ review community, which since then has grown to 250+ members on reddit. There has been great feedback and discussions since then, so that the idea is now ready to be tested. With August, the first review period has started
By Felix Petriconi | Aug 1, 2017 11:33 PM | Tags: intermediate
In this article "No Bugs" Hare outlines the possibility to run C++ code in the major four web browsers.
(Not Really So) New Niche for C++: Browser!?
by "No Bugs" Hare
From the article:
For quite a long while, C++ had been losing popularity; for example, as reported in [Widman16], in 2016 it got 7% less of the listings on Dice.com compared with a year earlier; and according to [TIOBE17], from the C++ Golden Age in 2004 till 2017, the C++ share fell from ~17% to a measly 6%.
As all of us (as in, ‘hardcore C++ fans’) know , this has nothing to do with the deficiencies of C++; rather it is related to an observation that the time of downloadable clients (which was one of the main C++ strongholds) has changed into the time of browser-based clients – and all the attempts to get C++ onto browsers were sooo ugly (ActiveX, anyone?) that this didn’t really leave a chance to use C++ there.
Well, it seems that this tendency is already in the process of being reverted:
C++ can already run on all four major browsers – and moreover, it has several all-important advantages over JavaScript, too.
And this – not too surprisingly – is what this article is all about.
By Adrien Hamelin | Jul 24, 2017 01:00 PM | Tags: intermediate c++17
Do you know these new attributes?
C++17 attributes - maybe_unused, fallthrough and nodiscard
by Simon Brand
From the article:
C++17 adds three new attributes for programmers to better express their intent to the compiler and readers of the code: maybe_unused, fallthrough, and nodiscard. This is a quick post to outline what they do and why they are useful.
By Adrien Hamelin | Jul 24, 2017 12:51 PM | Tags: intermediate c++11
Quick A: To be able to know when to delete the control block.
Recently on SO:
Why shared_ptr's reference counting object needs to keep track of the number of weak_ptrs pointing to the object too?
std::weak_ptr
refers to the control block to know if the object still exists and if so, to provide astd::shared_ptr
to it when needed. For that reason, the control block must exist as long as either astd::weak_ptr
or astd::shared_ptr
exists. You need to track the number of instances ofstd::weak_ptr
to know when the last one is destroyed, just like forstd::shared_ptr
.
By Adrien Hamelin | Jul 20, 2017 12:49 PM | Tags: intermediate community
Quick A: Everyone by reading and applying the C++ standard.
Recently on SO:
How to (and who can) implement the standard library features defined by the C++ committee?
The committee does not release any reference implementations. In the early days, things got standardized and then the tool developers went away and implemented the standard. This has changed, and now the committee looks for features that have been implemented and tested before standardization.
Also major developments usually don't go directly into the standard. First they become experimental features called a Technical Specification or TS. These TS may then be incorporated into the main standard at a later date.
You are free to write you own implementation of the C++ standard library. Plum Hall has a test suite (commercial, I have no connection, but Plum Hall are very involved with C++ standardization).
I don't see any issue with not being conformant. Almost all implementations have some extensions. Just don't make any false claims, especially if you want to sell your product.
If you're interested in getting involved, this can be done via your 'National Body' (ANSI for the USA, BSI for the UK etc.). The isocpp web site has a section on standardization which would be a good starting place.
By Adrien Hamelin | Jul 19, 2017 12:17 PM | Tags: intermediate c++11
The stl can help you!
Your own error code
by Andrzej Krzemieński
From the article:
I was recently implementing the “classification of error conditions” in my application offered by the functionality behind
std::error_code
. In this post I want to share some of my experience and insight.
By Adrien Hamelin | Jul 10, 2017 12:14 PM | Tags: intermediate c++11
Quick A: Create member functions begin()
and end()
returning an iterator.
Recently on SO:
How to make my custom type to work with “range-based for loops”?
The standard has been changed since the question (and most answers) were posted in the resolution of this defect report.
The way to make a
for(:)
loop work on your type X is now one of two ways:
- Create member
X::begin()
andX::end()
that return something that acts like an iterator- Create a free function
begin(X&)
andend(X&)
that return something that acts like an iterator, in the same namespace as your type X.And similar for const variations. This will work both on compilers that implement the defect report changes, and compilers that do not.