intermediate

Preferring STL algorithms from algorithm and numeric -- makramkd

(Related note: If you haven't yet watched and grokked Sean Parent's wonderful C++ Seasoning talk from last fall's GoingNative conference, do yourself a favor and watch it. You will find it eye-opening. If you have already watched it, you might still find it worth a re-watch to fully absorb.)

Here's a nice case study of why not to roll your own algorithms, when C++ comes with a treasure chest full of pre-written, pre-debugged, and pre-optimized (in a good way) standard algorithms in the box:

Preferring STL algorithms from algorithm and numeric

by makramkd

From the article:

This post isn’t meant to be a documentation of the algorithm and numeric headers: you can find those readily at cppreference. In this post I’m going to try to convince people that write very similar algorithms to those in the standard library to not use these algorithms in production code, and to prefer ones from the STL.

Let’s get the show on the road. I’m going to start with the most simple one, because I just want to get my point across.

Programming Conversations Lecture Series -- Alexander Stepanov

alex-stepanov-programming-conversations.PNGYet again the wonderful ongoing video series from Alexander Stepanov and Paramjit Oberoi (A9 Organization):

Programming Conversations

Programming conversations is intended as an interactive course on programming. We'll try to practice the Socratic method: eventually there will be very little lecturing, and most of the time will be spent in discussions and in writing code together. We plan to cover a wide variety of topics, starting with the nature of programming, and continuing, in no particular order, with benchmarking, algorithms, data structures, caches, instruction level parallelism, generic programming, variable sized types, and Platonic ideas.

Most of the concepts are explained in terms of C++11/STL/Boost.

Source code is available.

 

 

 

 

CS 251: Intermediate Software Design in C++ -- Doug Schmidt

Doug Schmidt's C++-based software design course is available on YouTube.:

CS 251: Intermediate Software Design in C++

by Douglas Schmidt

This video playlist contains screencasts from a course I'm teaching on advanced C++ and object-oriented patterns/frameworks in the Spring of 2014 at Vanderbilt University. Please see http://www.dre.vanderbilt.edu/~schmidt/cs251/ for more information on this course.

Topics covered include:

  • Overview of C++ (3 lectures)
  • Overview of Subversion
  • Overview of the STL (8 lectures)
  • Overview of Patterns (2 lectures)
  • A Case Study of "Gang-of-Four" Patterns (8 lectures)

About the instructor:

Douglas C. Schmidt is a Professor of Computer Science, Associate Chair of the Computer Science and Engineering program, and a Senior Researcher at the Institute for Software Integrated Systems, all at Vanderbilt University. He has also been the Chief Technology Officer for the Software Engineering Institute at Carnegie Mellon University, where he was responsible for directing the technical vision and strategic R&D investments.

C++ developers will know of Doug particularly because of his widely-acclaimed ACE and related libraries.

Understanding the New Set and Map Containers in the C++11 Standard Library -- S Clamage and D Gove

On the Oracle Tech Network, a nice reminder of the still-"new"-to-some hash-based containers, co-authored by the chair of the U.S. C++ standards committee:

Understanding the New Set and Map Containers in the C++11 Standard Library

by Steve Clamage and Darryl Gove

From the article:

One of the areas in the new C++ standard that has seen the most enhancement is the Standard Library. The functionality that is most likely to be immediately useful to developers is the additions to the container classes. This article describes the new set and map containers.

Quick Q: Why does this function take a parameter by value? -- StackOverflow

A classic on SO:

Why do we copy then move?

I saw code somewhere in which someone decided to copy an object and subsequently move it to a data member of a class. This left me in confusion in that I thought the whole point of moving was to avoid copying. Here is the example:

struct S
{
    S(std::string str) : data(std::move(str))
    {}
};

Here are my questions:

  • Why aren't we taking an rvalue-reference to str?
  • Won't a copy be expensive, especially given something like std::string?
  • What would be the reason for the author to decide to make a copy then a move?
  • When should I do this myself?

Ponder the use of unique_ptr to enforce the Rule of Zero -- Marco Arena

Marco Arena points out an important difference between shared_ptr and unique_ptr regarding polymorphic deletion. The article also shows two ways to equip unique_ptr with a type-erased deleter, one with no usage of dynamic dispatching.

Ponder the use of unique_ptr to enforce the Rule of Zero

by Marco Arena

I read the article "Enforcing the Rule of Zero" from latest Overload (of ACCU) and I'd like to point out something that I misapprehended at a first reading. ... a clever point the author underlines is about polymorphic deletion: what to do when we want to support polymorphic deletion, or when our classes have virtual functions? ...

Then the author suggests to use a shared_ptr: ...

CppCon 2014 super early bird almost sold out -- ~20 tickets left

cppcon-144.PNGIf you've been thinking of registering for CppCon, you can save by doing it in the next couple of days. Over at CppCon.org, Boris Kolpackov reports:

Super Early Bird Last Chance

In the past couple of weeks a lot of C++ enthusiasts have registered for CppCon 2014 and as a result we only have about 20 super early bird entries left. If you are planning to attend, this is your last chance to register at the most affordable price.

After the limited Super Early Bird is full, Early Bird registration will be available until the end of June. Student registrations are also available at a heavily subsidized rate to ensure students can take advantage of the program.

See also the Call For Submissions to see the kinds of topics that you can expect to see covered.

 

Common Optimizations -- Andrzej KrzemieĊ„ski

Today from the desk of Andrzej:

Common Optimizations

by Andrzej Krzemieński

From the article:

Language designers, compiler and library vendors make a great effort to make your programs run faster and faster. This post is a tour of some common performance optimizations in C++.

Consider the following code that deals with std::string: ...

Parsing XML at the Speed of Light--Arseny Kapoulkine

Some high-performance techniques that you an use for more than just parsing, including this week's darling of memory management:

Parsing XML at the Speed of Light

a chapter from "The Performance of Open Source Applications"
by Arseny Kapoulkine

From the chapter:

This chapter describes various performance tricks that allowed the author to write a very high-performing parser in C++: pugixml. While the techniques were used for an XML parser, most of them can be applied to parsers of other formats or even unrelated software (e.g., memory management algorithms are widely applicable beyond parsers). ...

Optimizing software is hard. In order to be successful, optimization efforts almost always involve a combination of low-level micro-optimizations, high-level performance-oriented design decisions, careful algorithm selection and tuning, balancing among memory, performance, implementation complexity, and more. Pugixml is an example of a library that needs all of these approaches to deliver a very fast production-ready XML parser–even though compromises had to be made to achieve this. A lot of the implementation details can be adapted to different projects and tasks, be it another parsing library or something else entirely.

Continue reading...

C++ and Beyond Road Show 2014 -- September 29 - October 1, Stuttgart, Germany

Today on the C++ and Beyond blog, Scott Meyers announced that registration is now open for a C&B event in Germany this fall, largely repeating the C&B December 2013 material for the benefit of those who were not able to attend the sold-out event in December.

C&B 2014: September 29 - October 1 in Stuttgart!

with Scott Meyers, Herb Sutter, Andrei Alexandrescu

Maritim Hotel, Stuttgart, Germany
September 29 - October 1, 2014

Note: The web page for the event is in German, but the seminar itself will be given in English.

From the announcement:

You can think of this event as the C&B Road Show, because the organization is a little different from how we’ve done things in the past: Most of the talks will be updated versions of the presentations we gave at C&B 2013. (See the schedule here.) If you were unable to attend C&B this past December, this is your chance to see what you missed. ... [See the] web page for C&B 2014 for all the details of this event.

This will be the only C&B in 2014, so we hope to see you in Stuttgart at the end of September for the first-ever C&B in Europe!