python typing module: Mixin

It seem to be impossible for now. You can find a discussion about “Intersection” type in python/typing#123 repository. There is a similar feature on PEP-544 called Protocol, and you can merge mixins by merging mixin protocols. There is an implementation of PEP-544 called typing_extensions. Maybe you can try that with this library.

Enforce strong type checking in C (type strictness for typedefs)

For “handle” types (opaque pointers), Microsoft uses the trick of declaring structures and then typedef’ing a pointer to the structure: #define DECLARE_HANDLE(name) struct name##__ { int unused; }; \ typedef struct name##__ *name Then instead of typedef void* FOOHANDLE; typedef void* BARHANDLE; They do: DECLARE_HANDLE(FOOHANDLE); DECLARE_HANDLE(BARHANDLE); So now, this works: FOOHANDLE make_foo(); BARHANDLE make_bar(); void … Read more

Check at Compile-Time if Template Argument is void

You can use a helper class to fine tune specializations: template <typename F> struct wrapper {}; template <typename Res, typename… Args> struct wrapper<Res(Args…)> { static Res wrap(Res (WINAPI *f)(Args…), Args&& args…) { Res r = f(std::forward<Args>(args)…); // Blah blah return r; } }; template <typename… Args> struct wrapper<void(Args…)> { static void wrap(void (WINAPI *f)(Args…), Args&& … Read more