A technique for reducing SFINAE type trait boilerplate in C++ using a single macro called DEFINE_IF_COMPILES. The macro takes a trait name and an expression, then generates a full SFINAE-based type trait that checks whether the expression compiles for a given type. Examples include checking if a type is dereferenceable, has a begin() method, supports arithmetic operations, or has a serialize() method. The approach was inspired by a Fedor Pikus talk at CppCon 2015.
Sort: