April 2018

C++17: The two line visitor explained--Marius Elvert

The power of C++17.

C++17: The two line visitor explained

by Marius Elvert

From the article:

If you have ever used an “idiomatic” C++ variant datatype like Boost.Variant or the new C++17 std::variant, you probably wished you could assemble a visitor to dispatch on the type by assembling a couple of lambda expressions like this:

auto my_visitor = visitor{
  [&](int value) { /* ... */ },
  [&](std::string const& value) { /* ... */ },
};

Quick Q: With “-fno-exceptions”, what happens with “new T”?

Quick A: The behaviour will likely stay the same.

Recently on SO:

With “-fno-exceptions”, what happens with “new T”?

The way I understand it, operator new is defined by libstdc++. If you now compile your own code with -fno-exceptions, you cannot catch any exceptions, but you will still be linking against the normal version of libstdc++, which does throw an exception.

So yes, new T will throw an exception, even with -fno-exception.

However, if you compiled libstdc++ with -fno-exception as well, things become different. Now, new T cannot throw an exception but, if I read the libstdc++ manual right it will call abort() instead.

It seems that, if you want your new T to return NULL on failure, the only way is to explicitely specify nothrow...

Boost 1.67 released

Boost 1.67 is now available:

Boost Version 1.67.0

There are two new libraries:

  • Contract: Contract programming for C++. All contract programming features are supported: Subcontracting, class invariants, postconditions (with old and return values), preconditions, customizable actions on assertion failure (e.g., terminate or throw), optional compilation and checking of assertions, etc, from Lorenzo Caminiti.
  • HOF: Higher-order functions for C++, from Paul Fultz II.

Also, many updated libraries have been updated. See the announcement for details.

 

CppCast Episode 145: Blogging and Text Processing with Bartłomiej Filipek

Episode 145 of CppCast the only podcast for C++ developers by C++ developers. In this episode Rob and Jason are joined by Bartłomiej Filipek to discuss blogging, Simplifying C++ Code with C++17, and the work he's doing at Xara.

CppCast Episode 145: Blogging and Text Processing with Bartłomiej Filipek

by Rob Irving and Jason Turner

About the interviewee:

Bartłomiej Filipek (Bartek as a shorter version) is a C++ software developer at Xara where he works mostly on text features for advanced document editors. He works remotely from Cracow/Poland. Apart from graphics applications, Bartek also has experience with game development, large-scale systems for aviation, writing graphics drivers and even biofeedback. For seven years Bartek has been regularly blogging. In the early days the topic revolved around graphics programming, and now he focuses on Core C++. In his spare time, he loves assembling trains and Lego with his little son. And he's a collector of large Lego Star Wars models.

Which One Is Better: Map of Vectors, or Multimap?--Jonathan Boccara

Depends!

Which One Is Better: Map of Vectors, or Multimap?

by Jonathan Boccara

From the article:

While advising on how to make code more expressive on the SFME project, I came across an interesting case of choosing the right data structure, which I’ll share with you with the permission of the authors of the projects.

We had to associate a key with several values, and perform various operations. Should we use a map of vectors, or is a multimap more appropriate? Let’s see the case in more details, and compare the two solutions...

Overload 144 is now available

ACCU’s Overload journal of April 2018 is out. It contains the following C++ related articles.

Overload 144 is now available

From the journal:

Deeds not words
Women’s suffrage used the motto “Deeds not Words". Frances Buontempo applies this to programming. by Frances Buontempo

No News is Good News
Using ‘new’ without care can be slow. Paul Floyd uses Godbolt’s compiler explorer to see what happens when you do. by Paul Floyd

Monitoring: Turning Noise into Signal
Creating useful logging is a constant challenge. Chris Oldwood shows us how structured logging helps. by Chris Oldwood

The Interface to Component Pattern and DynaMix
Dynamic Polymorphism is hard in C++. Borislav Stanimirov demonstrates how the DynaMix library helps. by Borislav Stanimirov

5 Reasons NOT to Use std::ostream for Human-Readable Output
C++’s ostream can be hard to use. Sergey Ignatchenko suggests we use the {fmt} library instead. by Sergey Ignatchenko

Practical Cryptographical Theory for Programmers
Cryptography is a daunting subject. Deák Ferenc helps you get started. by Deák Ferenc

Ex Hackina
Machine Learning and AI are popular at the moment. Teedy Deigh takes the Turing test. by Teedy Deigh

2018-04 post-Jacksonville mailing available

The full 2018-04 mailing of new standards papers is now available.

 

2018-04 post-Jacksonville
N4729 WG21 telecon meeting: Modules TS publication Jonathan Wakely 2018-02-01 2018-04 WG21
N4730 WG21 pre-Jacksonville telecon minutes Jonathan Wakely 2018-03-02 2018-04 WG21
N4731 SC22 WG14 Liaison Report (C Standard) Barry Hedquist 2018-03-05 2018-04 WG21
N4732 WG21 2018-03 Jacksonville Minutes Patrice Roy 2018-04-02 2018-04 WG21
N4734 Working Draft, C ++ Extensions for Networking Jonathan Wakely 2018-04-04 2018-04 N4711 WG21
N4735 Networking TS - Editor's Report Jonathan Wakely 2018-04-04 2018-04 WG21
N4736 Working Draft, C ++ Extensions for Coroutines Gor Nishanov 2018-03-31 2018-04 N4723 WG21
N4737 Editor's report for the Coroutines TS Gor Nishanov 2018-03-27 2018-04 WG21
N4738 C++ Standardization Committee Meeting, HSR Rapperswil – Latest Info Peter Sommerlad 2018-04-01 2018-04 WG21
N4739 Jacksonville 2018 LEWG Summary Titus Winters 2018-03-27 2018-04 WG21
N4740 N4740 Editors' Report - Programming Languages - C++ Richard Smith 2018-04-02 2018-04 WG21
N4741 Working Draft, Standard for Programming Language C++ Richard Smith 2018-04-02 2018-04 N4727 WG21
N4742 Working Draft, Technical Specification for C++ Extensions for Parallelism Version 2 Jared Hoberock 2018-04-02 2018-04 N4725 WG21
N4743 Parallelism TS Editor’s Report, post-Jacksonville mailing Jared Hoberock 2018-04-02 2018-04 WG21
N4744 Programming Languages - Technical Specification for C++ Extensions for Parallelism Version 2 Jared Hoberock 2018-04-02 2018-04 WG21
P0052r7 Generic Scope Guard and RAII Wrapper for the Standard Library Peter Sommerlad, Andrew L. Sandoval 2018-03-26 2018-04 P0052r6 Library
P0122r7 span: bounds-safe views for sequences of objects Neil MacIntosh, Stephan T. Lavavej 2018-03-16 2018-04 P0122r6 Library Adopted 2018-03
P0194r6 Static reflection Matus Chochlik, Axel Naumann, David Sankel 2018-03-16 2018-04 P0194R5 Core, Library Adopted 2018-03
P0214r9 Data-Parallel Vector Types & Operations Matthias Kretz 2018-03-16 2018-04 P0214r8 Library Adopted 2018-03
P0318R1 unwrap_ref_decay and unwrap_reference Vicente J. Botet Escribá 2018-03-30 2018-04 P0318R0 Library
P0323r6 std::expected Vicente Botet, JF Bastien 2018-04-02 2018-04 P0323R5 Library
P0339R4 polymorphic_allocator<> as a vocabulary type Pablo Halpern, Dietmar Kühl 2018-04-02 2018-04 P0339R3 Library
P0355r7 Extending <chrono> to Calendars and Time Zones Howard E. Hinnant, Tomasz Kamiński 2018-03-16 2018-04 P0355R6 Library Adopted 2018-03
P0388R2 Permit conversions to arrays of unknown bound Robert Haberlach 2018-03-09 2018-04 P0388R1 Evolution
P0443r6 A Unified Executors Proposal for C++ Jared Hoberock, Michael Garland, Chris Kohlhoff, Chris Mysen, Carter Edwards, Gordon Brown 2018-04-02 2018-04 P0443R5 SG1, Library Evolution
P0466R2 Layout-compatibility and Pointer-interconvertibility Traits Lisa Lippincott 2018-03-29 2018-04 P0466R1 Evolution, Library Evolution, Library
P0479R5 Proposed wording for likely and unlikely attributes Clay Trychta 2018-03-16 2018-04 P0479R4 SG14, Core Adopted 2018-03
P0482R2 char8_t: A type for UTF-8 characters and strings Tom Honermann 2018-04-01 2018-04 P0482R1 Evolution, Library Evolution
P0528R2 The Curious Case of Padding Bits, Featuring Atomic Compare-and-Exchange JF Bastien, Michael Spencer 2018-03-16 2018-04 P0528R1 Core
P0542R4 Support for contract based programming in C++ J. Daniel Garcia 2018-04-02 2018-04 P0542R3 Evolution, Core
P0551R3 Thou Shalt Not Specialize std Function Templates! Walter E. Brown 2018-03-16 2018-04 P0551R2 Library Adopted 2018-03
P0561R4 An RAII Interface for Deferred Reclamation Geoff Romer, Andrew Hunter 2018-03-21 2018-04 P0561R3 SG1, Library
P0591R3 Utility functions to implement uses-allocator construction Pablo Halpern 2018-04-02 2018-04 P0591R2 Library
P0602R2 variant and optional should propagate copy/move triviality Zhihao Yuan 2018-03-12 2018-04 P0602R1 Library
P0634R3 Down with typename! Nina Ranns, Daveed Vandevoorde 2018-03-14 2018-04 P0634R2 Core Adopted 2018-03
P0664R2 C++ Coroutine TS Issues Gor Nishanov 2018-03-08 2018-04 P0664R1 Evolution, Library Evolution, Core
P0722R3 Efficient sized delete for variable sized classes Richard Smith, Andrew Hunter 2018-03-17 2018-04 P0722R2 Core, Library
P0732R1 Class Types in Non-Type Template Parameters Jeff Snyder, Louis Dionne 2018-03-30 2018-04 P0732R0 Evolution
P0753R2 Manipulators for C++ Synchronized Buffered Ostream Peter Sommerlad, Pablo Halpern 2018-03-16 2018-04 P0753R1 Library Adopted 2018-03
P0754R2 <version> Alan Talbot 2018-03-13 2018-04 P0754R1 Library Adopted 2018-03
P0780R2 Allow pack expansion in lambda init-capture Barry Revzin 2018-03-14 2018-04 P0780R1 Evolution Adopted 2018-03
P0782R1 Constraining Concepts Overload Sets Adam David Alan Martin, Erich Keane 2018-03-31 2018-04 P0782R0 Evolution
P0806R1 Deprecate implicit capture of this via [=] Thomas Köppe 2018-04-02 2018-04 P0806R0 Core
P0809R0 Comparing Unordered Containers Titus Winters 2017-10-12 2018-04 Library Evolution, Library Adopted 2018-03
P0811R2 Well-behaved interpolation for numbers and pointers S. Davis Herring 2018-03-29 2018-04 P0811R1 Library
P0820R3 Feedback on P0214 Tim Shen 2018-03-29 2018-04 P0820R2 Library Evolution
P0840R2 Language support for empty objects Richard Smith 2018-03-12 2018-04 P0840R1 Core Adopted 2018-03
P0858R0 Constexpr iterator requirements Antony Polukhin 2017-11-11 2018-04 Library Evolution, Library
P0887R1 The identity metafunction Timur Doumler 2018-03-18 2018-04 P0887R0 Library
P0888R0 C++ Standard Library Issues to be moved in Jacksonville Marshall Clow 2018-02-12 2018-04 WG21
P0898R1 Standard Library Concepts Casey Carter 2018-04-02 2018-04 P0898R0 Library Evolution, Library
P0903R1 Define basic_string_view(nullptr) Ashley Hedberg 2018-02-16 2018-04 P0903R0 Library Evolution, Library
P0905R1 Symmetry for spaceship Tomasz Kamiński, Herb Sutter, Richard Smith 2018-03-16 2018-04 P0905R0 Evolution, Library Evolution Adopted 2018-03
P0906R1 Improvement suggestions for the Modules TS Jens Maurer 2018-04-02 2018-04 P0906R0 Core
P0907R1 Signed Integers are Two’s Complement JF Bastien 2018-04-01 2018-04 P0907R0 Evolution
P0911R1 Rebase the Coroutines TS onto the C++17 Standard Gor Nishanov 2018-03-15 2018-04 P0911R0 Core, Library Adopted 2018-03
P0913R1 Add symmetric coroutine control transfer Gor Nishanov 2018-03-15 2018-04 P0913R0 Evolution Adopted 2018-03
P0914R1 Add parameter preview to coroutine promise constructor Gor Nishanov 2018-03-15 2018-04 P0914R0 Evolution Adopted 2018-03
P0918R1 More simd<> Operations Tim Shen 2018-03-29 2018-04 P0918R0 SG1, Library Evolution
P0919R1 Heterogeneous lookup for unordered containers Mateusz Pusz 2018-04-01 2018-04 P0919R0 Library
P0929R1 Checking for abstract class types Jens Maurer 2018-03-24 2018-04 P0929R0 Core
P0943R1 Support C atomics in C++ Hans-J. Boehm 2018-03-30 2018-04 P0943R0 Library Evolution
P0947R1 Another take on Modules Richard Smith 2018-03-06 2018-04 P0947R0 Evolution
P0961R1 Relaxing the structured bindings customization point finding rules Ville Voutilainen 2018-03-14 2018-04 P0961R0 Evolution Adopted 2018-03
P0962R1 Relaxing the range-for loop customization point finding rules Ville Voutilainen 2018-03-14 2018-04 P0962R0 Evolution Adopted 2018-03
P0966R1 string::reserve Should Not Shrink Mark Zeren, Andrew Luo 2018-02-08 2018-04 P0966R0 Library Evolution, Library Adopted 2018-03
P0968R0 Core Language Working Group "tentatively ready" Issues for the March, 2018 (Jacksonville) meeting William M. Miller 2018-03-12 2018-04 WG21 Adopted 2018-03
P0969R0 Allow structured bindings to accessible members Timur Doumler 2018-03-14 2018-04 Evolution, Core Adopted 2018-03
P0970R0 Better, Safer Range Access Customization Points Eric Niebler 2018-04-01 2018-04 Library Evolution
P0973R0 Coroutines TS Use Cases and Design Issues Geoff Romer, James Dennett 2018-03-23 2018-04 Evolution
P0974R0 A Function Returning Whether An Underlying Type Value Is a Valid Enumerator of a Given Enumeration Jonathan Ringle 2018-03-30 2018-04 Library Evolution, Library
P0975R0 Impact of coroutines on current and upcoming library facilities Gor Nishanov 2018-03-10 2018-04 SG1, SG14, Evolution, Library Evolution, Library
P0976R0 The Evils of Paradigms Bjarne Stroustrup 2018-03-06 2018-04 WG21
P0978R0 A Response to "P0973r0: Coroutines TS Use Cases and Design Issues" Gor Nishanov 2018-03-31 2018-04 Evolution
P0981R0 Halo: coroutine Heap Allocation eLision Optimization: the joint response Richard Smith, Gor Nishanov 2018-03-18 2018-04 Evolution
P0982R0 Weaken Release Sequences Hans-J. Boehm, Olivier Giroux, Viktor Vafeiades 2018-04-01 2018-04 SG1, Core
P0983R0 Plan of Record for Making C++ Modules Available in C++ Standards Gabriel Dos Reis, Richard Smith 2018-04-01 2018-04 WG21
P0984R0 All (*)()-Pointers Replaced by Ideal Lambdas Peter Sommerlad 2018-04-01 2018-04 Evolution, Library Evolution
P0985R0 LWG Chair post-meeting report Marshall Clow 2017-03-31 2018-04 WG21
P0986R0 Comparison of Modules Proposals Richard Smith, David Jones 2018-03-09 2018-04 Evolution
P0987R0 polymorphic_allocator<byte> instead of type-erasure Pablo Halpern 2018-04-02 2018-04 Library
P0989R0 Standardizing Extended Integers Tony Van Eerd 2018-04-01 2018-04 Evolution
P0990R0 Rebuttal of Implementation Concerns for Bit Entanglement Tony Van Eerd 2018-04-01 2018-04 Evolution
P0991R0 Comparison of Stackful Coroutine Proposals Detlef Vollmann 2018-03-12 2018-04 SG1
P0992R0 Translation and evaluation Andrew Sutton 2018-04-02 2018-04 SG7
P0993R0 Value-based Reflection Andrew Sutton, Herb Sutter 2014-04-02 2018-04 SG7
P0994R0 String View Conversion for Function Arguments Adam David Alan Martin, Jason Carey 2018-03-20 2018-04 Library Evolution
P0995R0 Improving atomic_flag JF Bastien, Olivier Giroux, Andrew Hunter 2018-03-17 2018-04 SG1, Library Evolution
P0996R1 Rebase Library Fundamentals TS on C++17 Alisdair Meredith 2018-03-16 2018-04 P0996R0 Library Evolution, Library Adopted 2018-03
P0999R0 More Natural Arithmetic in C++ James Dennett 2018-­04-­01 2018-04 SG6, SG12, Evolution, Core
P1000R0 C++ IS schedule Herb Sutter 2018-04-02 2018-04 WG21
P1001R0 Target Vectorization Policies from Parallelism V2 TS to C++20 Alisdair Meredith 2018-03-14 2018-04 SG1, Library Evolution
P1001R1 Target Vectorization Policies from Parallelism V2 TS to C++20 Alisdair Meredith 2018-03-16 2018-04 P1001R0 SG1, Library Evolution
P1002R0 Try-catch blocks in constexpr functions Louis Dionne 2018-04-01 2018-04 Evolution
P1003R0 C++ Standard Library Issues Resolved Directly In Jacksonville Marshall Clow 2018-03-16 2018-04 WG21 Adopted 2018-03
P1004R0 Making std::vector constexpr Louis Dionne 2018-04-01 2018-04 Library Evolution
P1005R0 namespace std { namespace fs = filesystem; } Bryce Adelstein Lelbach, S. Davis Herring 2018-03-16 2018-04 SG3, Library Evolution, Library
P1006R0 Constexpr in std::pointer_traits Louis Dionne 2018-04-01 2018-04 Library Evolution
P1011R0 Constant Pointer View - std::as_const Strikes Back! Adam David Alan Martin 2018-03-20 2018-04 Library Evolution
P1013R0 Explicit concept expressions Thomas Köppe, Hubert S.K. Tong 2018-04-02 2018-04 Evolution
P1014R0 A Unit Type for C++ Andrew Sutton, Nevin Liber 2018-04-01 2018-04 Evolution
P1015R0 WG21 2018-03 Jacksonville Record of Discussion Patrice Roy 2018-04-02 2018-04 WG21
P1018R0 Evolution status after Jacksonville 2018 Ville Voutilainen 2018-03-18 2018-04 WG21

CopperSpice: Type Traits & Documentation

New videos on the CopperSpice YouTube Channel:

Type Traits

by Barbara Geller and Ansel Sermersheim

About the video:

This video covers Type Traits, what they are, and when you might want to use them. We also contrast Type Traits with Policy Classes, and show how the distinction can be very difficult to discern.

Using Doxypress

by Barbara Geller and Ansel Sermersheim

About the video:

This video is an overview of the DoxyPress C++ documentation generator. We also discuss the DoxyPressApp GUI frontend, and explain the structure and features of DoxyPress.

Please take a look and remember to subscribe!