News

C++11 and Boost

What issues arise when combining C++11 and (older) Boost code that has pre-standard versions of C++11 features?

C++11 and Boost

by Jens Weller

From the article:

Some parts of the Standard Library in C++11 are predated in boost. When playing around with C++11, you get used to using some parts in the Standard Library that are used in C++03 with their boost counterpart. Also, there is some libraries now occuring, which are C++11 based, so interfacing with either boost or C++11 code is soon an issue.

No Runtime Overhead -- Bulldozer00

sharedunique.pngA little nugget about the free-as-in-no-overhead-ness of unique_ptr and std::move:

No Runtime Overhead

by Bulldozer00

From the article:

Unless I really need shared ownership of a dynamically allocated object, which I haven’t so far, I stick to the slimmer and more performant std::unique_ptr. ...

Out Parameters, Move Semantics, and Stateful Algorithms -- Eric Niebler

In this article, Eric Niebler discusses an issue of API design regarding the age-old question of out parameters versus return-by-value, this time in light of move semantics. He uses std::getline as his example.

Out Parameters, Move Semantics, and Stateful Algorithms

by Eric Niebler

From the article:

I think getline is a curious example because what looks at first blush like a pure out parameter is, in fact, an in/out parameter; on the way in, getline uses the passed-in buffer’s capacity to make it more efficient. This puts getline into a large class of algorithms that work better when they have a chance to cache or precompute something.

 

Double-Checked Locking Is Fixed in C++11 -- Jeff Preshing

preshing.PNGJeff Preshing gives a nice overview of the on-again/off-again/on-again status of a common approach to lazy initialization.

[Ed: Note that DCLP is not just for thread-safe singletons, that's just a handy example. It's for lazy initialization in general.]

Double-Checked Locking Is Fixed in C++11

by Jeff Preshing

From the article:

The double-checked locking pattern (DCLP) is a bit of a notorious case study in lock-free programming. Up until 2004, there was no safe way to implement it in Java. Before C++11, there was no safe way to implement it in portable C++.

As the pattern gained attention for the shortcomings it exposed in those languages, people began to write about it. In 2000, a group of high-profile Java developers got together and signed a declaration entitled “Double-Checked Locking Is Broken”. In 2004, Scott Meyers and Andrei Alexandrescu published an article entitled “C++ and the Perils of Double-Checked Locking”. Both papers are great primers on what DCLP is, and why, at the time, those languages were inadequate for implementing it.

All of that’s in the past. Java now has a revised memory model, with new semantics for the volatile keyword, which makes it possible to implement DCLP safely. Likewise, C++11 has a shiny new memory model and atomic library which enable a wide variety of portable DCLP implementations. C++11, in turn, inspired Mintomic, a small library I released earlier this year which makes it possible to implement DCLP on some older C/C++ compilers as well.

In this post, I’ll focus on the C++ implementations of DCLP...

New "using std::cpp" event in Spain (Spanish only)

Ready for a full day of C++11/14/17 content in the Spanish language?

using std:cpp

November 26, 2013

University Carlos III of Madrid in Leganés

The site and the event are entirely in Spanish. For convenience, here is an automatic translation of the event page:

Welcome to using std::cpp 2013

using std::cpp 2013 aims to be a forum for exchanging experiences using the C++ language, paying special attention to the recent standard C++11 and the upcoming C++14 and C++17.

Who should attend using std::cpp 2013?

The event is aimed at professional developers using C++ as a language for application development or infrastructure software. It is also aimed at students of last years of career, interested in the use of C++ as a programming language to produce complex computer systems with high performance.

What can I find in using std:cpp 2013?

We have prepared an intensive programme with presentations by leading developers from leading companies in their sectors (Indizen, TCP-SI, BBVA, Telefónica, Digital, INDRA, Biicode, Microsoft, Programming Research Group).

You can refer to the detailed program to see topics you can expect.

When does using std::cpp take place?

using std::cpp 2013 will be held on November 26, 2013 at the School Politécnica Superior of the Universidad Carlos III de Madrid in Leganes and will last for a full day.

Do I need to register?

using std::cpp 2013 attendance is free, but you must register to facilitate the organization of the event. You can register here.

What are the semantics of =delete? -- StackOverflow

The question, rephrased: Does =delete mean "make the compiler skip this function and keep looking," or "make this function unusable and make the caller fix their code" -- and why?

What's the exact semantics of a deleted function in C++11?

struct A
{
    A();

    A(const A&);
    A& operator =(const A&);

    A(A&&) = delete;
    A& operator =(A&&) = delete;
};

struct B
{
    B();

    B(const B&);
    B& operator =(const B&);   
};

int main()
{
    A a;
    a = A(); // error C2280

    B b;
    b = B(); // OK
}

My compiler is VC++ 2013 RC.

error C2280: 'A &A::operator =(A &&)' : attempting to reference a deleted function

I just wonder why the compiler doesn't try A& operator =(const A&); when A& operator =(A&&) is deleted?

Is this behavior defined by the C++ standard?

Effective GoF Patterns with C++11 and Boost -- Tobias Darm

tobias-darm.PNGSpeaking of ACCU 2014, here's an excellent talk from ACCU 2013 showing how C++11 (by itself, and/or with Boost) makes expressing many common design patterns far simpler than using traditional pre-C++11 tools. In fat, are there cases where the design patterns even disappear entirely? Watch to find out.

Effective GoF Patterns with C++11 and Boost (slides)

by Tobias Darm

Abstract and bio:

Tobias Darm discusses how some of the GoF patterns can be implemented differently in C++11 using Boost libraries.

Tobias Darm is working with C++ and programming embedded devices used in an intensive care environment at Dräger medical. He likes to learn and teach about software development and does tutorials and workshops in his company encouraging a modern programming style.

 

ACCU 2014 call for papers is now open

Preparations are underway for the ACCU 2014 conference, to be held April 8-12, 2014 somewhere in the U.K. The conference has historically had strong C++ representation, and this year features a keynote by Howard Hinnant, longtime ISO C++ participant and former Library Working Group chair, and now a principal developer on Clang's libc++ implementation of the ISO C++ standard library. It also includes sessions on other languages and environments besides C++.

The conference has issued a call for papers which will close on Monday, November 5. From the call:

We have a long tradition of high quality sessions covering many aspects of software development, from programming languages (e.g., Java, Javascript, C#, Clojure, Python, Erlang, Haskell, Ruby, Groovy, C, C++, etc.), and technologies (libraries, frameworks, databases, etc.) to subjects about the wider development environment such as testing, architecture and design, development process, analysis, patterns, project management, and softer aspects such as team building, communication and leadership.

Sessions are usually tutorial-based, presentations of case studies, or interactive workshops, but we are always open to novel formats.

Pre-conference workshops are all day. Main conference sessions are 90 minutes. There are also a few 45 minutes sessions (reserved for less experienced speakers).

[...]

The Call for Papers lasts 5 weeks and will close on Monday 5th November 2013. Remember, remember, the 5th of November...

Full conference schedule will be announced 1st Jan 2014.

See the call for details on how to submit a proposed session.

Bjarne Stroustrup speaking at UNT near Dallas: October 11

Bjarne Stroustrup will be giving his "The Essence of C++" talk live in person next week at the UNT College of Engineering near Dallas, TX, USA.

The Essence of C++

by Bjarne Stroustrup

Location: UNC College of Engineering (map)
Friday, October 11, 2013
Talk: 2:00 p.m. –- 3:30 p.m.
Reception: 3:30 -- 4:00 p.m.

Abstract

C++11 is being deployed and the shape of C++14 is becoming clear. This talk examines the foundations of C++. What is essential? What sets C++ apart from other languages? How does new and old features support (or distract from) design and programming relying on this essence.

I focus on the abstraction mechanisms (as opposed to the mapping to the machine): Classes and templates. Fundamentally, if you understand vector, you understand C++.

Type safety and resource safety are key design aims for a program. These aims must be met without limiting the range of applications and without imposing significant run-time or space overheads. I address issues of resource management (garbage collection is not an ideal answer and pointers should not be used as resource handles), generic programming (we must make it simpler and safer), compile-time computation (how and when?), and type safety (casts belongs in the lowest-level hardware interface). I will touch upon move semantics, exceptions, concepts, type aliases, and more. My aim is not so much to present novel features and technique, but to explore how C++’s feature set supports a new and more effective design and programming style.