
9 Mar
2010
9 Mar
'10
1:29 p.m.
Can I ask inside a template function if a member exists on a parameter of the function.
For example.
template <typename T> void func(T in) { exists(in, foo); }
Where the "exists" line would return true if "in" had a member "foo" otherwise false.
Note, however, that "introspection" libarary cannot detect an inherited member. If you use MSVC and don't need a portable code, you can use __if_exists statement: http://msdn.microsoft.com/en-us/library/x7wy9xh3(VS.80).aspx