📜 ⬆️ ⬇️

Meeting C ++ 2013

Meeting C ++, Dusseldorf


It turned out that I was able to take part in the conference dedicated to C ++. The level, of course, is not GoingNative: the reports were of different levels. Both very strong and interesting, and completely empty. The most important thing for me was the atmosphere - for a long time I personally did not discuss so many interesting topics with anyone. I liked it so much that I had the idea of ​​creating a C ++ User Group in St. Petersburg in order to communicate more personally with colleagues in the workshop. But more about that later, but for now about the conference. I will not describe and retell all the reports; I will only note the most interesting topics and topics that were touched on in almost every report.

Key Trends


Move semantics

By itself, move-semantics, I think, is familiar to everyone. A quick search gives several posts on Habré ( 1 , 2 , 3 ). Almost every speaker squeezed something out of her. Of the interesting things, Eric Nibler speculated on how best to pass parameters to functions and what to return from them. Taking into account the sink-arguments and the fact that the compiler can recognize the rvalue, it turned out a great summary table 1 .
CategoryRecommendations for C ++ 11
Input Parameters :
small and sink values
other

Pass by value
const ref
Return valuePass by value
Input / Output ParametersWe use stateful algorithm object 2

Asynchrony

In addition to common words, such as “asynchrony begins with design”, complaints were mainly heard: after all, there is still no asynchronous I / O in the language. It is clear that an asynchronous program loses all meaning at synchronous input / output. Therefore, there was talk of future standards, of std :: async and std :: future, but, unfortunately, asynchrony in C ++ is more likely dead than alive. You can use many different good libraries or platform-specific solutions, but the language as it stood in this place is worth it.
According to the statements, the universal asynchronous model will be included only in C ++ 17. While you can get acquainted with its description here .
What exactly can we use while waiting for this paradise on earth? Nothing new!

Network

Everything is also as sad as asynchronous (if not worse). A representative of WG21 / SG4 (research group on the network standardization committee) led their roadmap for the coming years:

Personally, I am very depressed that HTTP will appear in the standard earlier than sockets. If I understand correctly, this is due to the fact that the demand for HTTP is much higher.
Productivity increase

As soon as we talk about improving performance, voices immediately burst into the conversation: “How can I correctly scale an application into several cores?” And “How can I optimize an application under embedded?”. If you think that C ++ and embedded are nonsense, here is a list of documents for your reference:

In the aspect of C ++ 11, both problems can be considered from a common point of view.

By the way, about std :: shared_ptr. In the Going Native'2012 review, there is a mention of why you should use std :: make_shared instead of the constructor std :: shared_ptr:
auto sp1 = make_shared<T>( args ); // 1 allocation, 24 bytes overhead shared_ptr<T> sp2( new T( args ) ); // 2 allocations, 40 bytes overhead 

Rainer Grimm was not too lazy to compare the performance of different approaches, including the usual pointers, std :: shared_ptr and std :: unique_ptr. 3
 auto st = std::chrono::system_clock::now(); for (long long i=0 ; i < 100000000; ++i){ int* tmp(new int(i)); delete tmp; // std::unique_ptr<int> tmp(new int(i)); // std::shared_ptr<int> tmp(new int(i)); // std::shared_ptr<int> tmp= std::make_shared<int>(i); } std::chrono::duration<double> dur=std::chrono::system_clock::now() - st(); std::cout << dur.count(); 

Got such a comparative table.
pointer typereal hardwarevirtualization
native3.0 sec.5.7 sec.
std :: unique_ptr2.9 sec.5.7 sec.
std :: shared_ptr6.0 sec.11.8 sec.
std :: make_shared6.5 sec.



Links
1. Eric Niebler, C ++ 11 and No-Compromise Library Design
2. Out Parameters, Move Semantics, and Stateful Algorithms
3. Rainer Grimm, Embedded Programming with C ++ 11

')

Source: https://habr.com/ru/post/203310/


All Articles