Meeting 20 June 2019

Hello World with reflection

/img/hello-world-meta.png

Higher-order functions

Meeting C++ 2018: Björn Fahller - Higher Order Functions for ordinary developers

A higher-order function is a function that takes other functions as arguments or returns a function as result.

Take-away messages:

  • Avoid using std::function as return type, use auto instead
  • Capturing by reference when returning a lambda is dangerous
  • Compose functions and give names to compositions
  • Functional extensions to std::optional and std::expected remove the need for many conditionals

https://github.com/rollbear/lift

Boost.HOF in Boost 1.68+ (Docs)

PacifiC++ 2018 - Titus Winters - C++ Past vs. Future

https://youtu.be/IY8tHh2LSX4

std::function const correctess bug

struct Callable {
    void operator()(){count++;}
    void operator()() const = delete;
    int count = 0;
};

void f() {
    Callable counter;
    std::function<void(void)> f = counter;
    f();
    const auto cf = f;
    cf(); // ???
}

PacifiC++ 2018 - Titus Winters - C++ Past vs. Future (cont.)

std::function requires copyable callables

void f() {
    std::unique_ptr<int> up;
    auto l=[up=std::move(up)](){};
    std::function<void(void)> f=l; // Build fails
}

PacifiC++ 2018 - Titus Winters - C++ Past vs. Future (cont.)

ODR violation

namespace libs {
inline bool contains(std::string_view needle, std::string_view haystack) {
    assert(needle.size() <= haystack.size()); // !!!
    return haystack.find(needle) != std::string_view::npos;
}
}

Catch V2.9.0

https://github.com/catchorg/Catch2/releases/tag/v2.9.0

This release replaces the old benchmarking support with a new one, based on donated Nonius code.

Taskflow V2.2.0

Cpp-Taskflow is by far faster, more expressive, and easier for drop-in integration than existing parallel task programming libraries such as OpenMP Tasking and Intel TBB FlowGraph in handling complex parallel workloads.

https://github.com/cpp-taskflow/cpp-taskflow/releases/tag/v2.2.0 (MIT)

Docs: https://cpp-taskflow.github.io/cpp-taskflow/index.html

Twitter

/img/turner-hpp.png

Quote

/img/theory-practice.png