Hello,
I have two functions that operate in much the same way on two different kinds of vectors.
if we allow
thenCode:typedef pair<num_t, num_t> point;
one operates onand the other operates onCode:vector< pair< point , vector<point> > >whereCode:vector< span >
So the first function does something involving vec[i].dy, and the other does the same thing using vec[i].second.size(), both for each element of vec.Code:struct span { num_t x; num_t dy; } //It's essentially a pair, but I didn't want the 'first' and 'second' syntax.
How can I write these two as one general function, without the use of helper classes? The functions are small enough that writing it twice is not so horrible, but if there is a straightforward template method, that'd be better.
Thanks.



LinkBack URL
About LinkBacks


