jamoma / jamoma2

A header-only C++ library for building dynamic and reflexive systems with an emphasis on audio and media.
MIT License
30 stars 6 forks source link

Compile Time Checks #46

Open tap opened 9 years ago

tap commented 9 years ago

Sweep through to improve type-safety and static_asserts.

Here is a related trick that recently came across my screen:

We can take one from optional's book and fake constrain the constructor to avoid implicit conversions:

struct bar {
  template <typename T, typename = std::enable_if_t<std::is_same<T, in_place_t>{}>>
  bar(in_place_t(*)(T)){}
};
tap commented 9 years ago

http://en.cppreference.com/w/cpp/types/is_same http://stackoverflow.com/questions/16924168/compile-time-function-for-checking-type-equality