
i got a thought remember my discussion about hierarchy of expression types in general a more specific expression derives from general expression: template<typename type> class specific_expression : public expression<type> {}; suppose you don't want to abandon policy drived creation of objects like 'object<some_type, specific>' then to provide behavior such that operations on specific objects handle them specifically (yielding specific result) we can provide that policies drive also the type of expression an object belongs to struct default_policy { template<typename type> struct expr { typedef expression<type> type; }; }; struct specific //specific policy { template<typename type> struct expr { typedef specific_expression<type> type; }; }; template<typename some_type, typename policy = default_policy> class object : public typename policy::expr<object<some_type, policy> >::type { //^^CRTP here //interface }; then we can write object<t> o1, o2, o3; o3 = some_op(o1, o2); //using general (not specialized) version //... object<t, specific> s1, s2, s3; s3 = some_op(s1, s2); //using specialized version //... o3 = some_op(o1, s2); //using general version s3 = some_op(s1, o2); //error: can not assign result (general //one) to specific object //(or can - design decision) this is also trivially extended by the (naive) user: class myobject : public specific_expression<myobject> {/*...*/}; //... myobject m; s3 = some_op(m, s2); //still using specialized version although it compiles with msvc80 i don't know if it is portable in general (there could be an issue deriving from dependent type) to joel: #1: all of this, i suppose, can be easily implemented within your policy system (if not yet) #2: do you use CRTP for policies itself? to restrict usages like this: matrix<double, settings( symmetric, 42 ) > m; i think it's a good idea, then settings() becomes something like template<typename p1, typename p2> <resulting_policy_type> settings(policy<p1>, policy<p2>); -- Pavel