Thanks, Sylvain to point to that. :)The use case is similar and a little different.Boost Concept Check will fail if not meet requirements.I would like a way to test it and return boolean.
For example, I would like do something like below:
struct default_foo{ void foo();};
struct user_foo{ void foo();};
template <typename T>void call_foo(typename if_
Date: Sat, 22 Nov 2014 22:44:49 +0800 From: sylvain.bougerel.devel@gmail.com To: boost@lists.boost.org Subject: Re: [boost] Is there interest in a library for testing existence of a function member of class?
Hi Wei,
Have you checked Boost Concept Check library, it looks like it could fit your use case.
Regards, Sylvain On 22 Nov 2014 22:33, "胡维"
wrote: Hi, I am looking for how to test if a function member of class exist or not in compile time.I did not find a solution by google so I wrote a piece of code for it.Please let me know if it's already in boost. :) Synopsis class Bar { public: Bar(int); };
class Foo { public: Foo(int); int foo(Bar); };
// create struct 'has_foo' which is used to test function member 'foo'.HAS_FUNCTION_MEMBER(foo)
int main() { assert((!has_foo
::value)); assert((has_foo ::value)); return 0; } The code is in my gisthttps://gist.github.com/wehu/1987f716074904d26cf0 The code only checks if the function is compatible with expected, but not require to be exact same. Thanks,Wei _______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
_______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost