Testing algorithms don't use more than a concept provides
I'm trying to verify an algorithm doesn't use more than a certain concept provides. For example, if the algorithm checks for an ForwardIterator it must not use the i-- operator. I'm currently testing this by creating a minimal abstract class for each concept and then testing if the algorithm compiles using only the minimal as input. I have a few issues with this approach. 1. I have to maintain two definitions, one concept and one minimal implementation. 2. I have to write minimal implementations for all the boost/stl containers/concepts I want to use. I guess someone must have had the same problem before, is there a better way to do this? Maybe even some existing boost functionality I am unaware of? In code: ------------------------ #define CONCEPT_USER(function, call, targ1) \ struct ConceptUser_##function##_##targ1 \ { \ targ1& _1; \ void Check() \ { \ function##call; \ } \ }; struct Interface { virtual void Foo() const = 0; }; template<typename T> void f(int n, const T& t) { t.Foo(); } CONCEPT_USER(f, (47, _1), Interface); // Compiles template<typename T> void g(double x, const T& t) { t.Foo(); t.Bar(); } CONCEPT_USER(g, (3.14, _1), Interface); // Compile Error. g also uses the function Bar. ------------------------ -- View this message in context: http://www.nabble.com/Testing-algorithms-don%27t-use-more-than-a-concept-pro... Sent from the Boost - Users mailing list archive at Nabble.com.
participants (1)
-
athor