News

Meeting C++ is sold out!

Last week the last ticket for Meeting C++ has been sold:

Meeting C++ is sold out for now

by Jens Weller

from the Article:

Ticket sales have been strong all summer long, and those who have yet not got their ticket will have to wait, maybe even for next year. There might be a second batch of tickets, which will not be more then 10-30 tickets released at the beginning of November. But for now, we are at almost 300 Attendees for Meeting C++! This includes the 50 Students, the speakers, the staff and all sold tickets.

A Video Interview with Herb Sutter on C++ Standards -- Brian Overland

sutter-overland.PNGAt CppCon last month, InformIT recorded this video interview. It has now been posted: 

A Video Interview with Herb Sutter on C++ Standards

with Brian Overland

From the synopsis:

Herb Sutter ... talks with Brian Overland about how the standards committee evaluates proposals, the importance of being egoless, how to submit a proposal to the standards committee, why the committee decided to update the standard every three years, and the adoption of C++ in cross-platform mobile apps.

Today: Community Planning Session

Today is the community planning session:

This Thursday: Community Planning Session

We'll meet at #meetingcpp in freenode at 17:00 CET!

From the article:

For the second time, we'll have the communtiy planning session happening at the freenode channel #meetingcpp. It will officially last one hour, but most likely be again the full evening a very busy chat. Last time we had guests from Europe, the US and Brazil...

Lightweight C++ options parser -- Jarryd Beck

Two regular expressions can go a long way.

Lightweight C++ options parser

by Jarryd Beck

From the article:

Using the new C++11 regular expressions, command line option parsing becomes trivial. I wrote a lightweight command line options parser because I was unsatisfied with all of the other libraries out there...

User-defined literals -- Marius Bancila

Today on the Codexpert blog:

User-defined literals

by Marius Bancila

From the article:

The C++11 standard introduced the possibility to create user-defined literals, that are basically built-in type literals (integer, float, char or string) followed by a used-defined suffix. User-defined literals enable the creation of new objects based on the built-in literal value and the applied user-defined suffix.

auto temp = 77_fah;       // 77 Fahrenheit degrees = 25 Celsius degrees

auto size = 1_KB;         // 1 kilobyte = 1024 bytes

auto emp  = "marius"_dev; // a user defined type Developer 

Ranges for the Standard Library -- Eric Niebler

Fresh over the weekend, and in this morning's Standardization feed:

N4128: Ranges for the Standard Library

by Eric Niebler

From the article:

Eleven months ago, I began work on an updated range library for modern C++. Yesterday, I submitted a proposal to the C++ standardization committee to add ranges to the Standard Library. The proposal presents a vision for a future Standard Library that is familiar and yet more powerful, more usable, and more efficient than today’s.

My goal is nothing less than to change how C++ programmers write code. Seriously.

Overload 123 is now available

overload-123.PNGOverload 123 is now available. It contains the following C++-related articles, and more:

 

Overload 123

Alternative Overloads

[No pun intended. --Ed.] How do you return a default value given a condition? Malcolm Noyes presents solutions using older and newer C++ techniques.

Debug Complexity: How Assertions Affect Debugging Time

Debugging any program can be time consuming. Sergey Ignatchenko and Dmytro Ivanchykhin extend their mathematical model to consider the effect of assertions.

Defining Visitors Inline in Modern C++

The Visitor pattern can involve non-local boilerplate code. Robert Mill and Jonathan Coe present an inline VISITOR in C++.

Quick Q: Why is "want speed? pass by value" not recommended? -- StackOverflow

Quick A: Because it performs worse than C++98 for common types like string and vector. The preferred way to optimize for rvalues is to add a && overload.

Fresh on SO:

Why is value taking setter member functions not recommended in Herb Sutter's CppCon 2014 talk (Back to Basics: Modern C++ Style)?

In Herb Sutter's CppCon 2014 talk Back to Basics: Modern C++ Style he refers on slide 28 (a web copy of the slides are here) to this pattern:

class employee {
  std::string name_;
public:
  void set_name(std::string name) noexcept { name_ = std::move(name); }
};

He says that this is problematic because when calling set_name() with a temporary, noexcept-ness isn't strong (he uses the phrase "noexcept-ish").

Now, I have been using the above pattern pretty heavily in my own recent C++ code mainly because it saves me typing two copies of set_name() every time -- yes, I know that can be a bit inefficient by forcing a copy construction every time, but hey I am a lazy typer. However Herb's phrase "This noexcept is problematic" worries me as I don't get the problem here: std::string's move assignment operator is noexcept, as is its destructor, so set_name() above seems to me to be guaranteed noexcept. I do see a potential exception throw by the compiler before set_name() as it prepares the parameter, but I am struggling to see that as problematic.

Later on on slide 32 Herb clearly states the above is an anti-pattern. Can someone explain to me why lest I have been writing bad code by being lazy?

Quick Q: Why did C++ add delegating constructors? -- StackOverflow

Quick A: Because they reduce code duplication, and so make code more readable and maintainable.

Recently on SO:

Why did C++11 introduce delegating constructors?

I cannot understand what the use is of delegating constructors. Simply, what cannot be achieve without having delegating constructors?

It can do something simple like this

class M
{
 int x, y;
 char *p;
public:
 M(int v) : x(v), y(0), p(new char [MAX]) {}
 M(): M(0) {cout<<"delegating ctor"<<endl;}
};

But I don't see it, is it worth introducing a new feature for such a simple thing? May be I couldn't recognize the important point. Any idea?

Ranges in C++: Counted Iterables and Efficiency -- Eric Niebler

New in Eric's series on ranges for C++:

Ranges in C++: Counted Iterables and Efficiency

by Eric Niebler

From the article:

I’ve been hard at work fleshing out my range library and writing a proposal to get range support into the standard. That proposal describes a foundational range concept: Iterable. An Iterable is anything we can pass to std::begin() and std::end() to get an Iterator/Sentinel pair. Sentinels, as I described here earlier this year, make it possible for the Iterable concept to efficiently describe other kinds of ranges besides iterator pairs.

The three types of ranges that we would like the Iterable concept to be able to efficiently model are:

  • Two iterators
  • An iterator and a predicate
  • An iterator and a count
The Iterator/Sentinel abstraction is what makes it possible for the algorithms to handle these three cases with uniform syntax. However, as Sean Parent pointed out here, the third option presents challenges when trying to make some algorithms optimally efficient. Back in February, when Sean offered his criticism, I promised to follow up with a blog post that justified the design. This is that post.