April 2015

CppCon 2014 0xBADC0DE--Jens Weller

While we wait for CppCon 2015 in September, we’re featuring videos of some of the 100+ talks from CppCon 2014. Here is today’s feature:

0xBADC0DE

by Jens Weller

(watch on YouTube) (watch on Channel 9)

Summary of the talk:

My motivation for this talk is my own expierence as a freelancer and trainer. I have seen a lot of good and bad code in different places. As a freelancer I often had to deal with different, unknown and often large codebases. This talk tries not only to show examples of bad code, but also to analyze why it exists in the first place, and how to deal with it or fix it. I'll visit anti-patterns, but this talk is not about anti-patterns, as that would only spotlight one of the many problems.

CLion 1.0, cross-platform C/C++ IDE, has finally arrived

CLion 1.0 is out.

JetBrains has finally released CLion - cross-platform IDE for C and C++ developers

By Anastasia Kazakova

From the article:

CLion is a full-featured IDE for developing in C and C++ on Linux, OS X or Windows. It's deeply integrated with the well-known CMake build system and GDB debugger, as well as with many popular Version Control Systems. CLion provides productivity boosting features, including smart editor, one-click navigation, reliable refactorings and on-the-fly code analysis with quick-fixes, to keep your C/C++ code high-quality.

C++11 is the second "most loved" language/technology on StackOverflow according to the survey

In case you missed it, an interesting data point about how much programmers appreciate the improvements in C++11 (and 14) compared to C++98. As Stroustrup frequently says, C++11 feel like a new language. Note “love” means in the sense of “enjoy programming in”… more people are willing to say they enjoy programming in modern C++, and C++11 truly was a turning point and progress is continuing:

C++11 is the second "most loved" language/technology on StackOverflow according to the survey

Quick Q: Can I do something like range-for with a counting loop?

Quick A: Yes. Start with boost::irange.

Recently on SO:

Can I do something like range-for with a counting loop?

Actually this are two related questions.

I know there is new syntax in C++11 for range based for loops of the form:

//v is some container
for(auto &i: v){
   // do something with i
}

First question: how can I infer at which iteration I am in this loop? (Say I want to fill a vector with value j at position j).

Second question: I wanted to now if there also is some other way to write a loop of the form

for(int i=0; i<100; i++){ ... }

I find this way of writing it a bit cumbersome and I do this so often and I would love to have a more concise syntax for it. Something along the lines:

for(i in [0..99]){ ... }

would be great.

For both questions I would like to avoid having to use additional libraries.

2015-04 pre-Lenexa mailing available

The 2015-04 mailing of new standards papers is now available.

NOTE: A number of these papers have already been publicized on this blog. This is the complete list including ones not previously publicized.

 

WG21 Number Title Author Document Date Mailing Date Previous Version Subgroup Disposition
N4381 Suggested Design for Customization Points Eric Niebler 2015-03-11 2015-04   Library  
N4382 Working Draft, C++ extensions for Ranges Eric Niebler 2015-04-12 2015-04   Library  
N4383 C++ Standard Library Active Issues List (Revision R92) Marshall Clow 2015-04-10 2015-04   Library  
N4384 C++ Standard Library Defect Report List (Revision R92) Marshall Clow 2015-04-10 2015-04   Library  
N4385 C++ Standard Library Closed Issues List (Revision R92) Marshall Clow 2015-04-10 2015-04   Library  
N4386 Unspecialized std::tuple_size should be defined Nevin Liber 2015-02-24 2015-04   Library  
N4387 Improving pair and tuple, revision 3 Daniel Krügler, Geoffrey Romer, Ville Voutilainen 2015-03-14 2015-04 N4064 Library  
N4388 A Proposal to Add a Const-Propagating Wrapper to the Standard Library Jonathan Coe, Robert Mill 2015-02-25 2015-04 N4372 Library  
N4389 Wording for bool_constant, revision 1 Zhihao Yuan 2015-02-23 2015-04 N4334 Library  
N4390 Minimal incomplete type support for standard containers, revision 3 Zhihao Yuan 2015-02-24 2015-04 N4371 Library  
N4391 make_array, revision 4 Zhihao Yuan 2015-02-26 2015-04 N4315 Library  
N4392 C++ Latches and Barriers Alasdair Mackintosh, Olivier Giroux 2015-03-03 2015-04 N4204 Library  
N4393 Noop Constructors and Destructors Pablo Halpern 2015-04-10 2015-04   Evolution  
N4394 Agenda for Lenexa Meeting Clark Nelson 2015-03-12 2015-04      
N4395 SIMD Types: ABI Considerations Matthias Kretz 2015-04-10 2015-04   Concurrency/Library  
N4396 National Body Comments: PDTS 19841, Transactional Memory Barry Hedquist 2015-03-16 2015-04   Transactional Memory  
N4397 A low-level API for stackful coroutines Oliver Kowalke 2015-04-09 2015-04 N3985 Concurrency  
N4398 A unified syntax for stackless and stackful coroutines Oliver Kowalke 2015-04-09 2015-04   Concurrency  
N4399 Proposed Working Draft, Technical Specification for C++ Extensions for Concurrency Artur Laksberg 2015-04-10 2015-04 N4107 Concurrency  
N4400 Concurrency TS Editor's Report, May 2015 Artur Laksberg 2015-04-10 2015-04   Concurrency  
N4401 Defaulted comparison operator semantics should be uniform Michael Price 2015-04-07 2015-04   Evolution  
N4402 Resumable Functions (revision 4) Gor Nishanov   missing   Evolution  
N4403 Draft Wording for Resumable Functions Gor Nishanov   missing   Evolution  
N4404 Extension to aggregate initialization Oleg Smolsky 2015-03-31 2015-04   Evolution  
N4405 Type of the accumulaters of standard algorithms std::accumulate and std::inner_product Vladimir Grigoriev 2015-02-11 2015-04   Library Evolution  
N4406 Integrating Executors with Parallel Algorithm Execution Jared Hoberock, Michael Garland, Oliver Giroux 2015-04-10 2015-04   Concurrency  
N4407 Working Draft, Technical Specification for C++ Extensions for Parallelism Jared Hoberock 2015-04-10 2015-04   Concurrency  
N4408 Parallelism TS Editor's Report Jared Hoberock 2015-04-10 2015-04   Concurrency  
N4409 Programming Languages -- Technical Specification for C++ Extensions for Parallelism Jared Hoberock 2015-04-10 2015-04   Concurrency  
N4410 Responses to PDTS comments on Transactional Memory Jens Maurer 2015-04-09 2015-04   Transactional Memory  
N4411 Task Block (formerly Task Region) R4 Pablo Halpern, Arch Robison, Hong Hong, Artur Laksberg, Gor Nishanov, Herb Sutter 2015-04-10 2015-04   Library Evolution, Concurrency  
N4412 Shortcomings of iostreams Jens Maurer 2015-04-09 2015-04   Library  
N4413 Constexpr Lambas Faisal Vali   missing   Evolution  
N4414 Executors and Schedulers Revision 5 Chris Mysen 2015-04-10 2015-04 N4143 Concurrency  
N4415 Simple Contracts for C++ Gabriel Dos Reis, J. Daniel Garcia, Francesco Logozzo, Manuel Fahndrich, Shuvendu Lahri 2015-04-12 2015-04   Evolution  
N4416 Don't Move: Vector Can Have Your Non-Moveable Types Covered Nevin Liber 2015-04-09 2015-04   Library Evolution  
N4417 Source-Code Information Capture Robert Douglas 2015-04-08 2015-04 N4129 Reflection  
N4418 Parameter Stringization Robert Douglas 2015-04-08 2015-04   Reflection  
N4419 Potential extensions to Source-Code Information Capture Robert Douglas 2015-04-08 2015-04   Reflection  
N4420 Defining Test Code Robert Douglas 2015-04-08 2015-04   Reflection  
N4421 Evolution Active Issues List (Revision R11) Ville Voutilainen 2015-04-10 2015-04      
N4422 Evolution Completed Issues List (Revision R11) Ville Voutilainen 2015-04-10 2015-04      
N4423 Evolution Closed Issues List (Revision R11) Ville Voutilainen 2015-04-10 2015-04      
N4424 Inline Variables Hal Finkel, Richard Smith 2015-04-07 2015-04   Evolution  
N4425 Generalized Dynamic Assumptions Hal Finkel 2015-04-07 2015-04   Evolution  
N4426 Adding [nothrow-] swappable traits Daniel Krügler 2015-04-10 2015-04   Library  
N4427 Agenda and Meeting Notice for WG21 Pre-Lenexa Telecon Meeting Herb Sutter 2015-04-08 2015-04      
N4428 Type Property Queries (rev 4) Andrew Tomazos, Christian Kaeser 2015-04-08 2015-04 N4113 Reflection  
N4429 Core issue 1941 - rewording inherited constructors Richard Smith 2015-04-10 2015-04   Evolution  
N4430 Core issue 1776 - replacement of class objects containing reference members Richard Smith 2015-04-10 2015-04 N4303 Core  
N4431 Working Draft, Standard for Programming Language C++ Richard Smith 2015-04-10 2015-04 N4296    
N4432 Editor's Report -- Working Draft, Standard for Programming Language C++ Richard Smith 2015-04-10 2015-04      
N4433 Flexible static_assert messages Michael Price 2015-04-09 2015-04   Evolution  
N4434 Tweaks to Streamline Concepts Lite Syntax Walter Brown 2015-04-10 2015-04   Evolution  
N4435 Proposing Contract Attributes Walter Brown 2015-04-09 2015-04   Evolution  
N4436 Proposing Standard Library Support for the C++ Detection Idiom Walter Brown 2015-04-09 2015-04   Library Evolution  
N4437 Conditionally-supported Special Math Functions, v3 Walter Brown 2015-04-09 2015-04 N3743 Library Evolution  
N4438 Industrial Experience with Transactional Memory at Wyatt Technologies. Brett Hall 2015-04-09 2015-04   Transactional Memory  
N4439 Light-Weight Execution Agents Revision 3 Torvald Riegel 2015-04-10 2015-04 N4156 Concurrency  
N4440 Feature-testing recommendations for C++ Clark Nelson 2014-04-10 2015-04 N4200 Feature Testing  
N4441 SG5: Transactional Memory (TM) Meeting Minutes 2015-03-23 and 2015-04-06 Michael Wong 2015-04-10 2015-04   Transactional Memory  
N4442 Default argument for second parameter of std::advance (Rev. 1) Vladimir Grigoriev 2015-04-09 2015-04 N4369 Library Evolution  
N4443 Introducing alias size_type for type size_t in class std::bitset (Rev. 1 ) Vladimir Grigoriev 2015-04-09 2015-04 N4368 Library Evolution  
N4444 Linux-Kernel Memory Model Paul E. McKenney 2015-04-10 2015-04 N4374 Concurrency  
N4445 Overly attached promise Agustín Bergé, Hartmut Kaiser 2015-04-09 2015-04   Concurrency  
N4446 The missing INVOKE related trait Agustín Bergé 2015-04-09 2015-04   Library Evolution  
N4447 From a type T, gather members name and type information, via variadic template expansion Cleiton Santoia Silva, Daniel Auresco 2015-04-10 2015-04 N3987 Reflection  
N4448 Rounding and Overflow in C++ Lawrence Crowl 2015-04-12 2015-04   Library Evolution  
N4449 Message Digest Library for C++ Zhihao Yuan 2015-04-09 2015-04   Library Evolution  
N4450 Variant: a typesafe union (v2) Axel Naumann 2015-04-13 2015-04 N4218 Library Evolution  
N4451 Static reflection Matúš Chochlík 2014-04-11 2015-04 N4111 Reflection  
N4452 Use cases of reflection Matúš Chochlík 2014-04-11 2015-04   Reflection  
N4453 Resumable Expressions Christopher Kohlhoff 2015-04-12 2015-04   Evolution  
N4454 SIMD Types Example: Matrix Multiplication Matthias Kretz 2015-04-10 2015-04   Concurrency  
N4455 No Sane Compiler Would Optimize Atomics JF Bastien 2015-04-10 2015-04   Concurrency  
N4456 Towards improved support for games, graphics, real-time, low latency, embedded systems Michael Wong 2015-04-12 2015-04   Evolution  
N4457 C++ Standard Core Language Active Issues, Revision 93 William M. Miller 2015-04-13 2015-04      
N4458 C++ Standard Core Language Defect Reports and Accepted Issues, Revision 93 William M. Miller 2015-04-13 2015-04      
N4459 C++ Standard Core Language Closed Issues, Revision 93 William M. Miller 2015-04-13 2015-04      
N4460 LWG 2424: Atomics, mutexes and condition variables should not be trivially copyable Ville Voutilainen 2015-04-07 2015-04   Evolution  
N4461 Static if resurrected Ville Voutilainen 2015-04-07 2015-04   Evolution  
N4462 LWG 2089, Towards more perfect forwarding Ville Voutilainen 2015-04-07 2015-04   Evolution  
N4463 IO device requirements for C++ Cleiton Santoia Silva, Daniel Auresco 2015-04-10 2015-04   I/O  
N4464 Pi-calculus syntax for C++ executors Cleiton Santoia Silva 2015-04-10 2015-04   Concurrency  
N4465 A Module System for C++ (Revision 3) Gabriel Dos Reis, Mark Hall, Gor Nishanov 2015-04-13 2015-04   Evolution  
N4466 Wording for Modules Gabriel Dos Reis 2015-04-13 2015-04   Evolution  
N4467 C++ Modules: Directions and Issues Gabriel Dos Reis   missing   Evolution  
N4468 On Quantifying Memory-Allocation Strategies John Lakos, Jeffrey Mendelsohn, Alisdair Meredith, Nathan Myers 2015-04-11 2015-04   Library Evolution  
N4469 Template Argument Type Deduction James Touton, Mike Spertus 2015-04-10 2015-04 N3601 Evolution  
N4470 Variadic lock_guard Mike Spertus 2015-04-10 2015-04   Concurrency  
N4471 Template parameter deduction for constructors (Rev 2) Mike Spertus 2015-04-12 2015-04 N3602 Evolution  
N4472 consexpr goto Ville Voutilainen 2015-04-10 2015-04   Evolution  
N4473 noexcept(auto), again Ville Voutilainen 2015-04-10 2015-04   Evolution  
N4474 Unified Call Syntax: x.f(y) and f(x,y) Bjarne Stroustrup, Herb Sutter 2015-04-12 2015-04   Evolution  
N4475 Default comparisons (R2) Bjarne Stroustrup 2015-04-09 2015-04 N4175 Evolution  
N4476 Thoughts about Comparisons (R2) Bjarne Stroustrup 2015-04-09 2015-04   Evolution  
N4477 Operator Dot (R2) Bjarne Stroustrup, Gabriel Dos Reis 2015-04-09 2015-04 N4173 Evolution  
N4478 Networking Library Proposal (Revision 5 Christopher Kohlhoff 2015-04-13 2015-04 N4370 Library Evoution  
N4479 Merge Fundamentals V1 into v2 Jeffrey Yasskin 2015-04-12 2015-04   Library Evoution  
N4480 Programming Languages -- C++ Extensions for Library Fundamentals DTS Jeffrey Yasskin 2015-04-07 2015-04      
N4481 Working Draft, C++ Extensions for Library Fundamentals, Version 2 Jeffrey Yasskin 2015-04-12 2015-04 N4336 Library Evolution  
N4482 Some notes on executors and the Networking Library Proposal Christopher Kohlhoff 2015-04-13 2015-04   Concurrency  

Quick Q: How is “=default” different from “{}” for default constructor and destructor?

Quick A: The "= default" keeps the type trivial.

Recently on SO:

How is “=default” different from “{}” for default constructor and destructor?

I originally posted this as a question only about destructors, but now I'm adding consideration of the default constructor. Here's the original question:

If I want to give my class a destructor that is virtual, but is otherwise the same as what the compiler would generate, I can use =default:

class Widget {
public:
   virtual ~Widget() = default;
};

But it seems that I can get the same effect with less typing using an empty definition:

class Widget {
public:
   virtual ~Widget() {}
};

Is there any way in which these two definitions behave differently?

Based on the replies posted for this question, the situation for the default constructor seems similar. Given that there is almost no difference in meaning between "=default" and "{}" for destructors, is there similarly almost no difference in meaning between these options for default constructors? That is, assuming I want to create a type where the objects of that type will be both created and destroyed, why would I want to say

Widget() = default;

instead of

Widget() {}

?

I apologize if extending this question after its original posting is violating some SO rules. Posting an almost-identical question for default constructors struck me as the less desirable option.

Boost.Spirit + Flatbuffers + Catch + Biicode + CLion + Github--Max Galkin

Come see a nice product review:

Boost.Spirit + Flatbuffers + Catch + Biicode + CLion + Github

by Max Galkin

From the article:

This weekend I’m test-driving several new technologies. OK, OK, maybe not so new for everyone else, but new for me. I’m trying to write a parser for the Flatbuffers IDL grammar using Boost.Spirit, I’m referencing Boost using Biicode, I’m testing the code using Catch, I’m editing the project in CLion, and I’m pushing the results to Github yacoder/flatbuffers-with-spirit!

Oral History of Bjarne Stroustrup

Oral History of Bjarne Stroustrup

About the interview:

In a substantial interview with Paul McJones, Bjarne Stroustrup discusses his youth, his education at the Aarhus University and the University of Cambridge, and his career at AT&T Bell Laboratories, Texas A&M University, and Morgan Stanley. Also covered are his early experience with a variety of programming languages including Simula and BCPL. Finally, the interview focuses on his work on C++ and its predecessor C with Classes, including his goal of combining good abstraction mechanisms with direct access to the hardware. Specific language features discussed include value semantics, templates, concepts, the Standard Template Library, and highlights of the C++11 and C++14 standards.

CppCon 2014 Pragmatic Type Erasure: Solving OOP Problems w/ Elegant Design Pattern--Zach Laine

While we wait for CppCon 2015 in September, we’re featuring videos of some of the 100+ talks from CppCon 2014. Here is today’s feature:

Pragmatic Type Erasure: Solving OOP Problems w/ Elegant Design Pattern

by Zach Laine

(watch on YouTube) (watch on Channel 9)

Summary of the talk:

There are numerous, serious OOP design problems that we have all encountered in production code. These include, among others: - object lifetime/ownership - how to make classes from different class hierarchies conform to a common interface - writing classes that can present multiple interfaces - separating interface and implementation - how to write virtual functions so that subclasses override them properly - the virtual inheritance "diamond of death"

Proper use of type erasure can mitigate, or outright eliminate, these and other problems, without sacrificing performance.

This talk will cover the OOP design problems above and more, and will cover hand-rolled and library-based type erasure approaches that solve those problems. Performance metrics will be provided for the different approaches, and source code will be available after the talk.