R
red floyd
I know it's generally bad from to derive from STL containers. That
said, here's my question:
I am using std:riority_queue<>. However, I need to be able to access
the underlying container; specifically, I need to be able to get at
begin() and end() for it.
Josuttis (10.3.3) shows that the compare operator and the container are
*protected* members of std:riority_queue. This would lead me to
believe that it was intended for derivation. I was thinking about doing
something like this:
class my_data { /* contents redacted */ };
class my_priority_queue : private std:riority_queue<my_data>
{
public:
typedef std:riority_queue<my_data> pq;
using pq::top;
using pq:ush;
using pq:op;
using pq::empty;
using pq::size;
my_priority_queue();
~my_priority_queue();
void do_something_to_all_elements(); // uses c.begin() and c.end()
};
Is this kosher?
said, here's my question:
I am using std:riority_queue<>. However, I need to be able to access
the underlying container; specifically, I need to be able to get at
begin() and end() for it.
Josuttis (10.3.3) shows that the compare operator and the container are
*protected* members of std:riority_queue. This would lead me to
believe that it was intended for derivation. I was thinking about doing
something like this:
class my_data { /* contents redacted */ };
class my_priority_queue : private std:riority_queue<my_data>
{
public:
typedef std:riority_queue<my_data> pq;
using pq::top;
using pq:ush;
using pq:op;
using pq::empty;
using pq::size;
my_priority_queue();
~my_priority_queue();
void do_something_to_all_elements(); // uses c.begin() and c.end()
};
Is this kosher?