chenshuo/recipes

How about replacing the 'if(0)' type check with type traits

Closed this issue · 1 comments

Wonderful example, just one comment, you hope to check if FUNC is the function type needed at compile time, how about use type traits? like:

include <type_traits>

// replace if(0) { xxxx } with following statement:
static_assert(std::is_same(FUNC, std::function<void(const State&)>)::value, "FUNC must be type of std::function<void(const State&)>");

no, func is not of type std::function, but callable with const State&
parameter.
On Oct 10, 2013 6:59 PM, "yuansip" notifications@github.com wrote:

Wonderful example, just one comment, you hope to check if FUNC is the
function type needed during compiling period, how about use type traits?
like:
#include

// replace if(0) { xxxx } with following statement:
static_assert(std::is_same(FUNC, std::function)::value, "FUNC must be type
of std::function");


Reply to this email directly or view it on GitHubhttps://github.com//issues/3
.