public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* question about HOWTO use std::set in non-trival way...
@ 2004-09-10 23:34 Jeffrey Holle
  2004-09-10 23:59 ` Eljay Love-Jensen
  0 siblings, 1 reply; 3+ messages in thread
From: Jeffrey Holle @ 2004-09-10 23:34 UTC (permalink / raw)
  To: gcc-help

I'm using gcc v3.4.1.

I've got an application that has a need for the following set container:

struct ltSubgraph : public binary_function<Edge,Edge,bool>
{
   ltSubgraph(const SubGraphT& subgraph);
   .....
};

typedef set<Edge,ltSubgraph> Edges;

The compare function requires that it has a SubGraphT object to 
implement its operator() method.

The question is how do I instanciate this container?

Just doing:
   Edges edges;

Produces errors for want of a ltSubgraph default constructor...

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: question about HOWTO use std::set in non-trival way...
  2004-09-10 23:34 question about HOWTO use std::set in non-trival way Jeffrey Holle
@ 2004-09-10 23:59 ` Eljay Love-Jensen
  2004-09-11  0:37   ` Jeffrey Holle
  0 siblings, 1 reply; 3+ messages in thread
From: Eljay Love-Jensen @ 2004-09-10 23:59 UTC (permalink / raw)
  To: jeff.holle, gcc-help

Hi Jeff,

Why does your ltSubgraph comparison function object class have a copy 
constructor?

See section 18.4.2 of Stroustrup's C++ Programming Language (3rd or special 
edition), for what a less functor object looks like.

HTH,
--Eljay

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: question about HOWTO use std::set in non-trival way...
  2004-09-10 23:59 ` Eljay Love-Jensen
@ 2004-09-11  0:37   ` Jeffrey Holle
  0 siblings, 0 replies; 3+ messages in thread
From: Jeffrey Holle @ 2004-09-11  0:37 UTC (permalink / raw)
  To: gcc-help

Found my own answer by looking at the implementation of set in 
bits/stl_set.h.
set has the approbriate constructor, so the answer is:
   Edges edges(ltSubGraph(graph_)).
A very thoughtful implementation!

Eljay Love-Jensen wrote:
> Hi Jeff,
> 
> Why does your ltSubgraph comparison function object class have a copy 
> constructor?
> 
> See section 18.4.2 of Stroustrup's C++ Programming Language (3rd or 
> special edition), for what a less functor object looks like.
> 
> HTH,
> --Eljay
> 
> 

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2004-09-11  0:37 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-09-10 23:34 question about HOWTO use std::set in non-trival way Jeffrey Holle
2004-09-10 23:59 ` Eljay Love-Jensen
2004-09-11  0:37   ` Jeffrey Holle

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).