So, I was wondering if it is possible to combine C++ adapters with library function objects in order to do some manipulation on containers defined in C++ standard library.
For example, if I were to define a vector with some elements
vector<int> vi={1,2,3,4,5,6,7,8,9,0};
and I want to count only the values contained in that vector that are greater than, for example, 4, I am interested in possibility of using an adapter:
priority_queue<int, vector<int>, greater<int> > pq(vi.begin(),vi.end());
However, it seems to me that previous line will just make a entire copy of vi
into pq
, while taking into account that the elements order is ascending. Is there a way to condition an adapter via greater<int>
to take into account only the specific values from the input vector?