Quick Q: Why is there a nonmember begin(), but no nonmember cbegin()? -- StackOverflow

Quick A: There is, in C++14.

From SO:

Is there a way to use standalone std::begin and for a const_iterator?

I like consistency. I recently asked the question of using std::begin vs. e.g. std::vector<int>::begin, and the unanimous decision seemed to be to use the former since it is more general. But I think I found a stick in the mud. Sometimes, you want to convey you will not change a container as you loop through it, hence calling std::vector<int>::cbegin. It would make your code quite asymmetric if you sometimes did iter = v.cbegin() and other times did iter = begin(v). Is there a way around this lack of symmetry, and would you still recommend std::begin given this knowledge? Why does C++ not have std::cbegin?

Core C++ #10 -- Stephan T. Lavavej

core-10.PNGAccompanying today's release of the VC++ CTP, there is a new talk by Stephan T. Lavavej available covering several major C++11 and draft C++14 features that are of likely interest to C++ developers using any compiler.

Core C++, 10 of n (Nov 2013 CTP)

by Stephan T. Lavavej

From the summary:

In part 10, STL explores the new features in the Visual C++ Compiler November 2013 CTP (Community Technology Preview), in addition to the features that were added between VC 2013 Preview and RTM.

Features included in the November CTP ( generic lambdas!!! Smiley ):

C++11, C++14, and C++/CX features:

  • Implicit move special member function generation (thus also completing =default)
  • Reference qualifiers on member functions (a.k.a. "& and && for *this")
  • Thread-safe function local static initialization (a.k.a. "magic statics")
  • Inheriting constructors
  • alignof/alignas
  • __func__
  • Extended sizeof
  • constexpr (except for member functions)
  • noexcept (unconditional)
  • C++14 decltype(auto)
  • C++14 auto function return type deduction
  • C++14 generic lambdas (with explicit lambda capture list)
  • (Proposed for C++17) Resumable functions and await

Visual C++ November 2013 CTP released, adds 13 new C++11/14 features

vc-ctp-nov13.PNGMicrosoft has announced a new Visual C++ Compiler CTP (Community Technology Preview):

Announcing the Visual C++ Compiler November 2013 CTP

In addition to the ISO C++ features added in last month's Visual c++ 2013 full release, this CTP adds the following additional ISO C++11 and draft ISO C++14 features in preview form:

  • Implicit move special member function generation (thus also completing =default)
  • Reference qualifiers on member functions (a.k.a. "& and && for *this")
  • Thread-safe function local static initialization (a.k.a. "magic statics")
  • Inheriting constructors
  • alignof/alignas
  • __func__
  • Extended sizeof
  • constexpr (except for member functions)
  • noexcept (unconditional)
  • C++14 decltype(auto)
  • C++14 auto function return type deduction
  • C++14 generic lambdas (with explicit lambda capture list)
  • (Proposed for C++17) Resumable functions and await

The new CTP installs as a new toolset under the Visual C++ 2013 IDE, allowing editing and building using the new Visual C++ compiler through the current shipping IDE. As this is a CTP, however, there is not yet other IDE support, and so for example the IDE may display red squiggles on valid code that will actually compile and run, as shown in the accompanying screenshot which exercises a generic lambda function having an auto parameter. If you do not already have a copy of Visual C++ 2013 installed and would like a free copy, several versions of the Visual C++ 2013 Express optimizing compiler are available for free via the Visual Studio Downloads page. 

New Stable Major wxWidgets 3.0.0 Release

logo9.jpgA new stable release of wxWidgets, the open source C++ library for creating cross-platform GUI applications with native look and feel, is now available.

This 3.0 release is a culmination of several years of work since the previous stable 2.8 series and so brings many important improvements compared to it, such as:

  • Much better and simpler to use support for Unicode.
  • New wxOSX/Cocoa port, suitable for development of 64 bit GUI applications under OS X.
  • Support for GTK+ 3 in wxGTK port.
  • Much improved documentation.
  • New webview library providing integration with the platform native HTML-rendering engine.
  • New propgrid and ribbon libraries.
  • New wxRichMessageDialog, wxInfoBar, wxCommandLinkButton, wxHeaderCtrl, wxRearrangeCtrl, wxTreeListCtrl, wxTimePickerCtrl, wxRichToolTip, wxBannerWindow, wxPersistentXXX and other classes.

as well as a huge number of other new features and bug fixes.

More information is available at wxWidgets home page and in the online documentation.

Quick Q: Can you move out of an initializer_list? -- StackOverflow

Quick A: No, because the contents are const.

A classic from SO, recommended by a developer team that encountered this situation again in the past week:

initializer_list and move semantics

Am I allowed to move elements out of a std::initializer_list<T>?

#include <initializer_list>
#include <utility>

template<typename T>

void foo(std::initializer_list<T> list)
{
    for (auto it = list.begin(); it != list.end(); ++it)
    {
        bar(std::move(*it));   // kosher?
    }
}

Since std::intializer_list<T> requires special compiler attention and does not have value semantics like normal containers of the C++ standard library, I'd rather be safe than sorry and ask.

The best of Boost, and using Boost the best

boost-books-2.pngWell timed with the recent release of Boost 1.55, a new Reddit thread just highlighted two useful books about Boost:

The first book is available online, with a second edition released in print in 2011:

The Boost C++ Libraries

by Boris Schäling

Table of Contents

  • Chapter 1: Introduction
  • Chapter 2: Smart Pointers
  • Chapter 3: Function Objects
  • Chapter 4: Event Handling
  • Chapter 5: String Handling
  • Chapter 6: Multithreading
  • Chapter 7: Asynchronous Input and Output
  • Chapter 8: Interprocess Communication
  • Chapter 9: Filesystem
  • Chapter 10: Date and Time
  • Chapter 11: Serialization
  • Chapter 12: Parser
  • Chapter 13: Containers
  • Chapter 14: Data Structures
  • Chapter 15: Error Handling
  • Chapter 16: Cast Operators

The second, the subject of the Reddit thread, was this new release:

Boost C++ Application Development Cookbook

by Antony Polukhin

Overview

  • Explores how to write a program once and then use it on Linux, Windows, MacOS, and Android operating systems
  • Includes everyday use recipes for multithreading, networking, metaprogramming,  and generic programming from a Boost library developer
  • Take advantage of the real power of Boost and C++ to get a good grounding in using it in any project

Table of Contents

  • Preface
  • Chapter 1: Starting to Write Your Application
  • Chapter 2: Converting Data
  • Chapter 3: Managing Resources
  • Chapter 4: Compile-time Tricks
  • Chapter 5: Multithreading
  • Chapter 6: Manipulating Tasks
  • Chapter 7: Manipulating Strings
  • Chapter 8: Metaprogramming
  • Chapter 9: Containers
  • Chapter 10: Gathering Platform and Compiler Information
  • Chapter 11: Working with the System
  • Chapter 12: Scratching the Tip of the Iceberg

Meeting C++ 2013

The recent Meeting C++ 2013 was a blast, the 2nd Meeting C++ conference was with over 200 guests a full success!

Meeting C++ 2013

by Jens Weller

Additional Online Resources:

Stephen Kelly about CMake for Qt and Boost

The talks from Peter Sommerlad

Sven Johannsens HTML based talk about STL11 is online.

Available slides are linked in the talk descriptions.

HPX version 0.9.7 released -- STE||AR Group, LSU

The STE||AR Group at Loisiana State University has released V0.9.7 of HPX -- A general purpose parallel C++ runtime system for applications of any scale.

HPX V0.9.7 Released

The newest version of HPX (V0.9.7) is now available for download! Over the past few months...

From the announcement:

  • Ported HPX to BlueGene/Q
  • Improved HPX support for Intel Xeon Phi® accelerators.
  • Reimplemented hpx::bind, hpx::tuple, and hpx::function for better performance and better compliance with the C++11 Standard. Added hpx::mem_fn.
  • Reworked hpx::when_all and hpx::when_any for better C++ compliance. Added hpx::when_any_swapped.
  • Added hpx::copy as a precursor for a migrate functionality, added hpx::get_ptr allowing to directly access the memory underlying a given component.
  • Added the hpx::lcos::broadcast, hpx::lcos::reduce, and hpx::lcos::fold collective operations.
  • Added support for more flexible thread affinity control from the HPX command line, such as new modes (balanced, scattered, compact), improved default settings when running multiple localities on the same node.
  • Added experimental executors for simpler thread pooling and scheduling. This API may change in the future as it will stay aligned with the ongoing C++ standardization efforts.
  • Massively improved the performance of the HPX serialization code. Added partial support for zero copy serialization of array and bitwise-copyable types.
  • General performance improvements of the code related to threads and futures.

Quick Q: Does using std:: smart pointers mean not using raw pointers? -- StackOverflow

Quick A: No. Smart pointers are for ownership. Raw pointers are still fine for non-owning pointers to an object that outlives the pointer.

C++11 Smart Pointer Semantics

I've been working with pointers for a few years now, but I only very recently decided to transition over to C++11's smart pointers (namely unique, shared, and weak). I've done a fair bit of research on them and these are the conclusions that I've drawn:

  1. Unique pointers are great. They manage their own memory and are as lightweight as raw pointers. Prefer unique_ptr over raw pointers as much as possible.
  2. Shared pointers are complicated. They have significant overhead due to reference counting. Pass them by const reference or regret the error of your ways. They're not evil, but should be used sparingly.
  3. Shared pointers should own objects; use weak pointers when ownership is not required. Locking a weak_ptr has equivalent overhead to the shared_ptr copy constructor.
  4. Continue to ignore the existence of auto_ptr, which is now deprecated anyhow.

So with these tenets in mind, I set off to revise my code base to utilize our new shiny smart pointers, fully intending to clear to board of as many raw pointers as possible. I've become confused, however, as to how best take advantage of the C++11 smart pointers. ...