October 2014

Urbana Proposals - C++17 insight?

I've started with my series on the proposals for the next C++ Committee Meeting:

Urbana Proposals - C++17 insight?

by Jens Weller

From the article:

A short series to give you an overview over the Papers submitted in the latest mailing for the C++ Committee Meeting in Urbana-Champaign in Illinois. At the beginning of November the C++ Committee will have its 3rd Meeting this year. As C++14 is now finished, the focus is clearly on the upcoming C++17 standard.

From the archives: "C++: as close as possible to C -- but no closer" -- A. Koenig and B. Stroustrup

n0007.PNGFor your Friday reading pleasure, we recently came across one of the very earliest C++ standardization papers written, with number N0007 (or call it "007"):

C++: as close as possible to C -- but no closer

by Andrew Koenig and Bjarne Stroustrup

It's interesting too see how much C++ has stayed true to its root design. And the thesis and contents of this paper are both remarkably current, and to be considered by those who would attempt to C-ify C++, or C++-ify C.

From the paper:

ANSI C and the C subset of C++ serve subtly different purposes. ...

The purpose of this note is to summarize the remaining differences between the draft ANSI C standard and C++, explain their motivation, and point out cases where these differences are less important than they might appear at first.

Italian C++ Community Meetup -- November 8, Bologna, Italy

it-meetup-2014-11.PNGThe next meetup of ++it (italiancpp.org, the Italian C++ Community) will be in Bologna, Italy, on November 8th.

Highlights

  • 1 interactive session.
  • 2x60' talks.
  • 2x30' lightning talks.
  • 1x45' Q/A panel.
  • Networking breaks and lunch.

Special speaker

  • Bartosz Milewski!

More details (in Italian) and registration (free) here.

Extension methods in C++ -- Marius Bancila

Recently on Codexpert, an enthusiastic and very readable reaction to two fresh standards proposals that will be considered two weeks from now at the ISO C++ meeting in Urbana-Champaign, Illinois, USA:

Extension methods in C++

by Marius Bancila

From the article:

... if x.f(y) and f(x,y) were equivalent it would be very easy to write the above code like this:

auto v = std::vector<int> {1,2,3,4,5,6,7,8,9};

auto s = v.where([](int e){return e % 2 == 0; })
          .select([](int e){return e*e; })
          .sum();

Isn’t that beautiful? I think it is.

...

The N4174 paper is rather an exploration of possibilities for uniform calling syntax than a very formal proposal. There are various aspects that have to be carefully considered especially when considering how to treat f(x, y). The N4165 paper makes a good case of the uniform calling syntax, explains the benefits better and argues against treating f(x) equivalent to x.f(). You should go ahead and read the two papers for detailed information. However, I sincerely hope that one day this will be accepted and become a core feature of the C++ language.

Quick Q: Does unordered_map<string,MyClass>::erase() destroy my MyClass objects? -- SO

Quick A: No, but unordered_map<string, unique_ptr<MyClass>>::erase and unordered_map<string, shared_ptr<MyClass>>::erase do.

Today on SO:

std::unordered_map<std::String, myClass*> -- does std::unordered_map::erase() call myClass' DTor?

Assume I have some unordered_map of pointers to class instances, would erasing an object from that map also delete the instance?

(rewording the question:) If I wanted to delete that instance, which version would be right?

if(it != map.end())
{
    delete it->second;
    map.erase(it);
}

or simply

if(it != map.end())
    map.erase(it);

?

Quick Q: Is there an alternative to PC-Lint that supports C++14? -- StackOverflow

It's not often we run a link to a SO article in the Product section, but this is a useful product question.

Alternative for PC-Lint supporting C++14 (Visual Studio 2013)

I am using PC-Lint for quite some time with very good results.

The last year however, I noticed that PC-Lint cannot keep up with the new C++ standards. E.g. range-based for-loops, variadic templates, make_unique, ... which are all constructions supported by Visual Studio 2013, aren't recognized by PC-Lint.

The result is that my code is now filled with lint-comments to disable checking on blocks of code using these constructions. This means:

  • less readable code
  • I'm almost spending more time updating my lint-comments that actually writing code

Is there an alternative (free or commercial) for PC-Lint on Windows that can keep up with the recent C++ standards?