August 2014

AST matchers and Clang refactoring tools -- Eli Bendersky

You can do some great things when you have a reusable open-source C++ parser:

AST matchers and Clang refactoring tools

by Eli Bendersky

From the article:

Clang tooling sees lots of interest and development focus in the past few years. At last, we have a convenient, accurate, open-source and well supported framework for programmatically analyzing and refactoring C++ code; I find this very exciting.

A great outcome of this rapid pace of development is that new APIs and tools spring up all the time. For example, some time ago the Clang tooling developers figured out folks doing AST traversals have to write a lot of repetitive code to find interesting AST nodes, so they came up with a great new API called AST matchers, which I want to discuss here...

N4126: Explicitly defaulted comparison operators -- Oleg Smolsky

A new WG21 paper is available. If you are not a committee member, please use the comments section below or the std-proposals forum for public discussion.

Document number: N4126

Date: 2014-07-29

Explicitly defaulted comparison operators

by Oleg Smolsky

Excerpt:

N3950 was presented to the Evolution WG at the Rapperswil meeting and the response was very positive. A later revision, N4114 was amended to handle the following points requested at the meeting:

  • Support for non-member operators
  • Mutable members: there was consensus on their treatment. The compromise is to to make explicitly defaulted operators ill-formed when mutable members are present. See "Mutable members".
  • Short-hand notation was proposed and had very positive feedback. See "The proposed syntax: short form".

This proposal makes the following changes after the technical review on the c++std-ext list:

  • Pointer, floating point and enumerated type members are included. See "Domain of the operator functions" for the discussion.
  • Each explicitly defaulted operator is independent and is bridged to the respective members' operators
  • Lexicographical comparison is defined explicitly

Quick Q: Why doesn't std::sort accept its comparator by reference? -- StackOverflow

Quick A: By design, because function objects are expected to be nonstateful values.

Recently on SO:

Why doesn't std::sort accept comparator by reference?

The standard on std::reference_wrapper explains that std::sort now accepts std::reference_wrapper, allowing one to pass a comparator by reference.

Is there a reason std::sort didn't accept the comparator by reference in the first place?

A Clang edition of the C++11/14 Rocks book is now available

Korban's C++11/14 feature overview book now has a Clang edition, in addition to VS2013 and GCC:

Clang Edition of the C++11/14 Rocks Book

by Alex Korban

From the announcement:

Do you use Clang to compile C++? Would you like to know all about the C++11 and C++14 language features it supports?

You can read about them in the new edition of my C++11/14 Rocks book tailored to Clang.

...

For those who have the GCC edition of the book: you’ll already be familiar with all the C++11 content as GCC also has full C++11 support. However, the Clang edition has full C++14 coverage instead of an overview.