advanced

Quick Q: How to require an exact function signature in the detection idiom?

Quick A: Use is_detected

Recently on SO:

How to require an exact function signature in the detection idiom?

With C++17 is_detected, you may do

template <typename T, typename Ret, typename Index>
using subscript_t = std::integral_constant<Ret (T::*) (Index), & T::operator[]>;

template <typename T, typename Ret, typename Index>
using has_subscript = is_detected<subscript_t, T, Ret, Index>;

static_assert(has_subscript<std::vector<int>, int&, std::size_t>::value, "!");
static_assert(!has_subscript<std::vector<int>, int&, int>::value, "!");

Zero-allocation continuations in C++17 — Vittorio Romeo

This series of articles show the design and implementation of future-like asynchronous computation chains that do not require any dynamic memory allocation or type erasure. 

by Vittorio Romero

From the article:

I'd like to show an alternative design [for futures] that doesn't require any allocation whatsoever and still enables users to build up asynchronous computation chains using facilities such as `when_all` and `.then`. [...] The idea behind it is to encode the entire computation chain into a single object with a huge type.

Fuzzing beast with libFuzzer

A short blog post about my experience in fuzzing beast during my boost review

Fuzzing beast with libFuzzer

by Jens Weller

From the article:

During the weekend I wanted to take a closer look at beast, a http library proposed for boost. I planned to write an http client class, as thats something I'll need in some project later anyways. I've been looking at beast on and off for a few month now, and started by reviewing the documentation and examples to get a feel for the library it self.

Making things do stuff - Part 6 and 7--Glennan Carnie

The series continues.

Making things do stuff

by Glennan Carnie

Part 6Part 7

From the article:

As code designers we tend to eschew specific ‘stove-pipe’ code in favour of reusable code elements.  Up until now we’ve been coding some very specific examples so it’s probably worth looking at some more generic solutions...

5 years of Meeting C++

Meeting C++ exists now for 5 years, lets celebrate on the blog:

5 years of Meeting C++

by Jens Weller

From the article:

Just a little bit more then 5 years ago, Meeting C++ went public. Since then, it has been a wild ride and huge success. Today, Meeting C++ reaches over 50k in social media, the conference it self has grown from 150 to 600 in its 5 editions...

CppCon 2016: C++14 Reflections Without Macros, Markup nor External Tooling..--Antony Polukhin

Have you registered for CppCon 2017 in September? Don’t delay – Registration is open now.

While we wait for this year’s event, we’re featuring videos of some of the 100+ talks from CppCon 2016 for you to enjoy. Here is today’s feature:

C++14 Reflections Without Macros, Markup nor External Tooling..

by Antony Polukhin

(watch on YouTube) (watch on Channel 9)

Summary of the talk:

C++ was lacking the reflections feature for a long time. But a new metaprogramming trick was discovered recently: we can get some information about POD structure by probing it's braced initializes. Combining that trick with variadic templates, constexpr functions, implicit conversion operators, SFINAE, decltype and integral constants we can count structure's fields and even deduce type of each field.

Now the best part: everything works without any additional markup nor macros typically needed to implement reflections in C++.

In this talk I'll explain most of the tricks in detail, starting from a very basic implementation that is only capable of detecting fields count and ending up with a fully functional prototype capable of dealing with nested PODs, const/volatile qualified pointers, pointers-to-pointers and enum members. Highly useful use-cases will be shown a the end of the talk. You may start experimenting right now using the implementation at https://github.com/apolukhin/magic_get.

Making things do stuff – Part 6--Glennan Carnie

The series continues.

Making things do stuff – Part 6

by Glennan Carnie

From the article:

As code designers we tend to eschew specific ‘stove-pipe’ code in favour of reusable code elements.  Up until now we’ve been coding some very specific examples so it’s probably worth looking at some more generic solutions.

In this article we’ll look at building generic register manipulation classes (or, as one commenter referred to them, ‘register proxy’ classes).  Here, we’re really exploring code design rather than coding ‘mechanics’.  I’m using this to explore some factors like the balance between efficiency, performance and flexibility...

Making things do stuff – Part 5--Glennan Carnie

The series continues.

Making things do stuff – Part 5

by Glennan Carnie

From the article:

We’ve been looking at using C++ to manipulate I/O hardware.   Previously, we’ve looked at the fundamentals of hardware manipulation; and how to encapsulate these mechanisms into classes.  If you’ve not been following along I’d recommend reading the previous articles first before continuing.

This time we’ll explore a lesser-known feature of C++ and its application in hardware manipulation – placement new...