I just learned that there is a a lot data structure are implemented in pb_ds. And also I'm new to learn template in c++. I try to use __gnu_pbds::priority_queue in template, but I got an error on line 24. Why does this not working?
#include<ext/pb_ds/priority_queue.hpp>
#include<functional>
#include<vector>
using std::greater,std::vector;
namespace working{
struct Struct
{
void run() {
using pq_t=__gnu_pbds::priority_queue<int,greater<int>>;
pq_t q;
vector<pq_t::point_iterator>it(10);
}
};
}
namespace not_working{
template<class T>
struct Struct
{
void run() {
using pq_t=__gnu_pbds::priority_queue<T,greater<T>>;
pq_t q;
vector<pq_t::point_iterator>it(10); //got error
}
};
}
int main() {
return 0;
}
error message:
error: type/value mismatch at argument 1 in template parameter list for ‘template<class _Tp, class _Alloc> class std::vector’
note: expected a type, got ‘pq_t::point_iterator’
error: template argument 2 is invalid