Meeting 2 November 2017

The C++ Bestiary

Website

CppCon 2017: Matt Godbolt - What Has My Compiler Done for Me Lately? Unbolting the Compiler’s Lid

CppCon 2017: Scott Wardle - EA’s Secret Weapon: Packages and Modules

  • Versions in library paths: not ideal
  • Masterconfig: Premake solves this much more elegantly, IMHO
  • EA package server: directory of packages
  • Disting is tricky (manual versioning)
  • Module example (MSVC-style); discusses how to find modules during build
  • EA packages can have circular link dependencies
  • Modules should have package as part of the name to avoid conflicts (naming convention). Better yet, there should be a package manager.
  • Q: “I’m coming from Rust and I don’t get the point of these modules”

CppCon 2017 Internet of Things Panel

  • Updating and fixing bugs is a problem, especially when the device is not supported anymore or the manufacturer goes out of business
  • Why would anyone want their fridge to connect to the Internet?
  • Early IoT adopters have quite a few paperweights
  • IoT security is a big issue and it is hard
  • Using exceptions may not be possible
  • IoT projects are excellent for getting children interested in programming and technology

Intel® System Studio 2018 Beta User Guide for IoT C/C++ Development

Supported boards:

CppCon 2017: John D. Woolverton - C Pointers

A lightning talk about learning from mistakes.

1/* add polygon to current grid position and advance */
2*((*(gridfill++))++) = poly;

DRES: Destruct Resources on Exit Scope (aka RAII)

Clara: A simple-to-use composable command line parser by Phil Nash

  • GitHub
  • C++11
  • Monadic binding for composability, no exceptions
  • Used by Catch, combines with user’s parsers
1int width = 0;
2using namespace clara;
3auto cli = Opt(width, "width")["-w"]["--width"]("How wide?");
4auto result = cli.parse(Args(argc, argv));
5if (!result) {
6    std::cerr << "Error: " << result.errorMessage() << std::endl;
7    exit(1);
8}

DLL: Deep Learning Library (!)

GitHub (MIT)

DLL is a library that aims to provide a C++ implementation of Restricted Boltzmann Machine (RBM) and Deep Belief Network (DBN) and their convolution versions as well. It also has support for some more standard neural networks.

  • Header-only
  • C++14
  • CUDA
  • Windows not supported (I’m guessing the author only vaguely knows about Windows, judging by the name of the library)
  • Dependencies:
    • Catch
    • cifar – Simple C++ reader for CIFAR-10 dataset
    • etl – Expression Templates Library (ETL) with GPU support
    • mnist – Simple C++ reader for MNIST dataset
    • libsvm – A Library for Support Vector Machines

C++/WinRT in Windows SDK

Post

Goal: to retire C++/CX

Download Windows Insider Preview SDK build 17025

Best unknown MSVC flag: /d2cgsummary

Post

Case study

  • Anomalistic compile times
  • Caching stats
  • Code generation summary
  • Name demangling: undname.exe or online demangler

ARM GCC Cross Compilation in Visual Studio

Post

Download the Visual Studio 2017 Preview, install the Linux C++ Workload, select the option for Embedded and IoT Development and give it a try with your projects.

CLion 2017.3 EAP

Post

Guide into OpenMP: Easy multithreading programming for C++

Link

 1#include <cmath>
 2int main()
 3{
 4    const int size = 256;
 5    double sinTable[size];
 6
 7    #pragma omp parallel for
 8    for(int n=0; n<size; ++n)
 9        sinTable[n] = std::sin(2 * M_PI * n / size);
10
11    // the table is now initialized
12}

A polymorphic value-type for C++

P0201R2 by Jonathan Coe and Sean Parent

 1// Copyable composite with mutable polymorphic components
 2class CompositeObject {
 3  std::polymorphic_value<IComponent1> c1_;
 4  std::polymorphic_value<IComponent2> c2_;
 5public:
 6  CompositeObject(std::polymorphic_value<IComponent1> c1,
 7                    std::polymorphic_value<IComponent2> c2) :
 8                    c1_(std::move(c1)), c2_(std::move(c2)) {}
 9  void foo() { c1_->foo(); }
10  void bar() { c2_->bar(); }
11};

Printing boolean values

1printf("%c", boolean_expr["NY"])