I'm new to the forum so forgive me if this has been discussed in the past. I was reading about new C++14 template constraints and other work with compile time reflection, and I thought that there may be a relatively simple mechanism which could be very useful in these categories.
What I am thinking is something like this:
std::has_member<&T::member, int(int)>::value
I'm not settled on has_member, perhaps "is_callable" would be a better fit, but that's an unimportant detail.
The idea being to test if there is a function in T, named "member" which has a signature matching "int member(int)". I believe that this would be require special compile support since if T::member doesn't exist, it would of course normally be compiler error to write things like &T::member.
The idea isn't quite fleshed out in my mind of how it could/should be implemented while still keeping with the spirit of C++, but I do feel that in general, the ability to test for the existence of a class member could be monumentally useful. It would allow things like:
* using static asserts to get better compiler errors when types are missing operators/member functions
* it would allow using enable_if to select a template specialization based on what a class supports which I think has interesting potential
Thoughts, Criticisms and Improvements are all welcome :-)
Evan