Compile time vs Run time Dependency – Java

Compile-time dependency: You need the dependency in your CLASSPATH to compile your artifact. They are produced because you have some kind of “reference” to the dependency hardcoded in your code, such as calling new for some class, extending or implementing something (either directly or indirectly), or a method call using the direct reference.method() notation. Run-time … 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

Is is_constexpr possible in C++11?

I once wrote it (EDIT: see below for limitations and explanations). From https://stackoverflow.com/a/10287598/34509 : template<typename T> constexpr typename remove_reference<T>::type makeprval(T && t) { return t; } #define isprvalconstexpr(e) noexcept(makeprval(e)) However there are many kinds of constant expressions. The above answer detects prvalue constant expressions. Explanation The noexcept(e) expression gives false iff e contains a potentially … Read more

Static assert in C

C11 standard adds the _Static_assert keyword. This is implemented since gcc-4.6: _Static_assert (0, “assert1”); /* { dg-error “static assertion failed: \”assert1\”” } */ The first slot needs to be an integral constant expression. The second slot is a constant string literal which can be long (_Static_assert(0, L”assertion of doom!”)). I should note that this is … Read more