This is a question regarding compile-time introspection in C++
Is there a known trick to detect that a matching function is actually private and thus can't be invoked? My intuitive guess is that this is not possible -- but maybe I'm wrong?
Explanation: using metaprogramming techniques (mostly based on the SFINAE mechanism), it is possible to detect the presence of properties (nested types, members, functions with specific signature) in a type given as template parameter (i.e. we know this type exists, but we don't know anything further about that type). Based on such introspection predicates, it is then possible to create specialised implementations, adapters, etc.
Now the specific twist is that such a predicate might match a private member of a class. When we subsequently generate code based on the result of that (false) match, the compilation fails, since we're actually not allowed to access that member. Thus a technique to sort out such false matches would be nice...
Aucun commentaire:
Enregistrer un commentaire