|
From: Ioannis V. <no...@ho...> - 2002-11-29 13:40:28
|
> -----Original Message-----
> From: dev...@li...
> [mailto:dev...@li...] On Behalf
> Of Marcos Carrard
> Sent: Thursday, November 28, 2002 9:11 PM
> To: dev...@li...
> Subject: [Dev-C++] STL problem
>
>
> Hi!
>
> I have a little problem with Dev in STL library. The problem is in
> priority_queue with declaration of function object for
> relational test.
> The source code is:
>
> #include <iostream>
> #include <queue>
// for less<>
#include <functional>
// See below
#include <vector>
>
> using namespace std;
>
> int main()
> {
> typedef priority_queue< int, less<int> > IntPQueue; // HERE!!!!
priority_queue has 3 types, the 2 last having defaults:
The second is the vector<> where it stores the elements and the third is
the less<> which by default uses <.
In few words your less is redundant (and may even induce additional time
cost). So if you want to define the third argument you have to define
the second too:
typedef priority_queue< int, vector<int>, less<int> > IntPQueue;
Ioannis Vranos
* Programming pages: http://www.noicys.freeurl.com
* Alternative URL: http://run.to/noicys
|