C++ Weekly Episode 6: Stop Using std::endl
Episode 7 of C++ Weekly.
Stop Using std::endl
by Jason Turner
About the show:
In this episode Jason tries to convince you to stop using std::endl by default.
March 11-13, Online
March 16-18, Madrid, Spain
March 23-28, Croydon, London, UK
May 4-8, Aspen, CO, USA
May 4-8, Toronto, Canada
June 8 to 13, Brno, Czechia
June 17-20, Folkestone, UK
September 12-18, Aurora, CO, USA
November 6-8, Berlin, Germany
November 16-21, Búzios, Rio De Janeiro, Brazil
By Jason Turner | Apr 18, 2016 11:10 PM | Tags: None
Episode 7 of C++ Weekly.
Stop Using std::endl
by Jason Turner
About the show:
In this episode Jason tries to convince you to stop using std::endl by default.
By Mantosh Kumar | Apr 17, 2016 09:45 PM | Tags: None

The schedule for the annual ACCU Conference has just been published. The conference will be held at Marriott Hotel City Centre, in Bristol, UK, on April 19-23, 2016. The conference is focused on professionalism in programming, but as always the schedule contains a lot of talks about C++.
ACCU is a small and friendly conference, typically 400+ attendees living together in the same hotel for a week discussing everything about programming. Most of the talks(60+) are 90 minutes, with long breaks inbetween, inviting to deep and insightful discussions both during and after the sessions. If you are into programming, especially C++, this is a conference that you might want to consider.
By Marco Arena | Apr 15, 2016 04:26 AM | Tags: basics
In this new post on Competitive Programming I introduce std::vector and std::accumulate:
C++ in Competitive Programming: warmup
by Marco Arena
From the article:
You are given an array of integers of size N. Can you find the sum of the elements in the array? ...
By Marco Arena | Apr 14, 2016 02:04 PM | Tags: visual studio
A new post from the Visual C++ Team:
STL Fixes In VS 2015 Update 2
by Stephan T. Lavavej
From the article:
The STL in VS 2015 Update 2 contains numerous improvements for correctness and performance...
By Adrien Hamelin | Apr 12, 2016 01:59 PM | Tags: intermediate community
ACCU’s Overload journal of April 2016 is out. It contains the following C++ related articles.
Overload 132
From the journal:
The Tao of Scratch
Scratch is an environment designed to help young people learn to code. Patrick Martin walks us through it. by Patrick Martin
Knowledge-Sharing Architects As An Alternative to Coding Architects
Should architects write code? Sergy Ignatchenko explores this controversial subject. by Sergey Ignatchenko
QM Bites: Understand Windows OS Identification Preprocessor Macros
There’s confusion between user-defined and predefined Windows 32/64-bit operating-system identification macros. Matthew Wilson shines light on the issue. by Matthew Wilson
Why Collaboration is Key for QA Teams in an Agile World
Agile processes can have an impact on QA departments. Greg Law considers how they can adapt to survive and even thrive. by Greg Law
How to Diffuse Your Way Out of a Paper Bag
Diffusion models can be used in many areas. Frances Buontempo applies them to paper bag escapology. by Frances Buontempo
Stufftar
How do you quickly transfer data from one machine to another? Ian Bruntlett shows us the bash script he uses. by Ian Bruntlett
QM Bites: looping for-ever
Never-ending loop constructs can confound user and compiler in subtle ways. Matthew Wilson offers advice to maximise portability and transparency.
Using Enum Classes as Bitfields
Scope enums have many advantages over standard enums. Anthony Williams shows how to use them as bitmasks. by Anthony Williams
9.7 Things Every Programmer Really, Really Should Know
Most of us have heard of the twelve step program. Teedy Deigh introduces a 9.7 step plan for programmers.
By Adrien Hamelin | Apr 12, 2016 11:41 AM | Tags: intermediate c++11
Quick A: No, it has changed.
Recently on SO:
Is Stephen Lavavej's Mallocator the same in C++11?
STL himself has an answer to this question in his STL Features and Implementation techniques talk at CppCon 2014 (Starting at 26'30).
The slides are on github.
I merged the content of slides 28 and 29 below:
#include <stdlib.h> // size_t, malloc, free #include <new> // bad_alloc, bad_array_new_length template <class T> struct Mallocator { typedef T value_type; Mallocator() noexcept { } // default ctor not required template <class U> Mallocator(const Mallocator<U>&) noexcept { } template <class U> bool operator==( const Mallocator<U>&) const noexcept { return true; } template <class U> bool operator!=( const Mallocator<U>&) const noexcept { return false; } T * allocate(const size_t n) const { if (n == 0) { return nullptr; } if (n > static_cast<size_t>(-1) / sizeof(T)) { throw std::bad_array_new_length(); } void * const pv = malloc(n * sizeof(T)); if (!pv) { throw std::bad_alloc(); } return static_cast<T *>(pv); } void deallocate(T * const p, size_t) const noexcept { free(p); } };Note that it handles correctly the possible overflow in allocate.
By Jason Turner | Apr 11, 2016 09:53 AM | Tags: None
Episode 6 of C++ Weekly with Jason Turner.
Intro To Variadic Templates
by Jason Turner
About the show:
In this episode Jason gives a brief introduction to C++ variadic templates and covers some compile time and runtime performance considerations.
By Blog Staff | Apr 9, 2016 03:18 PM | Tags: None
A repeat of last year's popular course, again being held in English and German:
Boost Your Productivity with Modern C++
by Peter Gottschling
Abstract:
Templates (generic programming)
- Function templates
- Class templates
- Variadic Templates (C++11)
- Concepts
- Specialization
- Template arguments that are not types
- Functors
- Lambda functions (C++11)
Standard Template Library
- Iterator concept
- Containers
- Functions
- Meta-programming
- Let the compiler compute
- Providing type informations
- Auto and decltype (C++11)
- Const-adaptive classes
- Expression templates
Other advanced and new techniques
- Calling functions from derived classes without overhead
- RValues and move semantics (C++11)
- Initialization lists (C++11)
- New for-loops (C++11)
Peter Gottschling is author of the Matrix Template Library 4, co-author of the Boost Graph Library and other scientific libraries. He is vice-chair of DIN's programming language group and head of the German delegation in the ISO committee for C++ standardization. He is managing director of SimuNova and taught C++ at TU Dresden, TU Berlin and Indiana University.
By Adrien Hamelin | Apr 8, 2016 01:05 PM | Tags: intermediate experimental
Quick A: An easy solution is not supported by the standard, it may come later.
Recently on SO:
Is it possible in C++ to do std::map<> “for element : container” iteration with named variables (eg, key and value) instead of .first and .second?
You could write a class template:
template <class K, class T> struct MapElem { K const& key; T& value; MapElem(std::pair<K const, T>& pair) : key(pair.first) , value(pair.second) { } };with the advantage of being able to write
keyandvaluebut with the disadvantage of having to specify the types:for ( MapElem<int, std::string> kv : my_map ){ std::cout << kv.key << " --> " << kv.value; }And that won't work if
my_mapwereconsteither. You'd have to do something like:template <class K, class T> struct MapElem { K const& key; T& value; MapElem(std::pair<K const, T>& pair) : key(pair.first) , value(pair.second) { } MapElem(const std::pair<K const, std::remove_const_t<T>>& pair) : key(pair.first) , value(pair.second) { } }; for ( MapElem<int, const std::string> kv : my_map ){ std::cout << kv.key << " --> " << kv.value; }It's a mess. Best thing for now is to just get used to writing
.firstand.secondand hope that the structured bindings proposal passes, which would allow for what you really want:for (auto&& [key, value] : my_map) { std::cout << key << " --> " << value; }
By Adrien Hamelin | Apr 8, 2016 12:49 PM | Tags: c++11 advanced
How will you move?
Sessions and object lifetimes
by Andrzej Krzemieński
From the article:
In this post we will see how C++ object lifetime can be used to control the duration of sessions: time spent owing and using a resource. The goal is to get a better understanding of what tools the language offers for using and sharing resources efficiently...