Hello,
I would like to use sorted stl container with particular sorting policy:
Element of the container is composed of several prioritized sub elements and the sort policy respect a hierachical ordering policy of the subelemnts:
1 2 3 4 5 6 7 8 9
example :
pseudotype A{
int i;
}
pseudotype B{
int j;
}
an example of sorted AB container would be { (i=0,j=0), (i=0,j=1), (i=1,j=0),(i=1,j=1)} ..its first sorted on A prop then on B prop
I hope im clear...
For this i create this pattern:
sorry, i don't understand your answer ...I have correct a little mistake with NULLCLASS 's operators that shouldnt be virtual but that work great...
But that doesnt solve my original question about performance issue of such a pattern...
Ideally i want to break the inheritance chain in order to avoid potential heavy polymorphic call (when inheritance chain become very long till break the call stack)...
Any idea?
The best way to avoid inheritance is to not use it.
1 2 3 4 5 6 7 8 9 10 11 12 13
template <class First, class Second>
class pair{
public:
First first;
Second second;
booloperator<(const pair<First, Second> &b) const{
return
first<b.first
or not b.first<first
and second < b.second;
}
};
Yeah thanks for the answer but for recursive definitiion of the policy it doesnt work well as it put the different composite on differents levels, it's not easy to manipulate for the user......
I will though about setter functors in order to wrap the depth of such a pattern