[Bug libstdc++/18174] New: documentation example for std::priority_queue usage

2004-10-27 Thread Number_42 at caramail dot com
I just wanted to add an std::priority_queue usage example in the documentations,
since it's not obvious when you don't know how tu use it.

Since there isn't an "html" target in the root Makefile of gcc i didn't check
for validity of the patch, but i think it's ok.

$ uuencode priority_queue-3.4.1.patch.uu < priority_queue-3.4.1.patch  
  
begin 600 priority_queue-3.4.1.patch.uu
M9&EF9B`M<[EMAIL PROTECTED]PHK("[EMAIL PROTECTED]@
M<'5B;&[EMAIL PROTECTED]("[EMAIL PROTECTED]@("`@($EN="AI;G0@:2D**R`@("H@("`@("`@("`@
M.B!I7RAI*0HK("[EMAIL PROTECTED]@("`@('L**R`@("H@("`@("!]"BL@("`J"BL@("`J
M("`@("`@:6YT(&E?.PHK("[EMAIL PROTECTED]@?3L**R`@("H**R`@("H@('-T9#HZ;W-T
M7!E9&5F('-T9#HZ<')I
M;W)I='E?<75E=64\($EN="`J+"!V96-T;W)?='[EMAIL PROTECTED]5]Q=65U95]T>7!E.PHK("[EMAIL PROTECTED]@HK("[EMAIL 
PROTECTED]@=F]I9`HK("[EMAIL PROTECTED]@
M9F]O*"D**R`@("H@('L**R`@("H@("`@("!V96-T;W)?='EP92!V.PHK("`@
[EMAIL PROTECTED]("[EMAIL PROTECTED]@("`@('8N<'5S:%]B86-K*&YE=R!);G0H."DI.PHK("[EMAIL 
PROTECTED]@
M("`@('8N<'5S:%]B86-K*&YE=R!);G0H,2DI.PHK("[EMAIL PROTECTED]@("`@('8N<'5S
M:%]B86-K*&YE=R!);G0H-2DI.PHK("[EMAIL PROTECTED]@HK("[EMAIL PROTECTED]@("`@('!R:6]R:71Y
M7W%U975E7W1Y<&4@<'$H=BYB96=I;[EMAIL PROTECTED]"!V+F5N9"@I*3L**R`@("H**R`@
M("H@("`@("!W:&EL92`H(7!Q+F5M<'1Y*"DI"BL@("`J("`@("`@>PHK("`@
M*B`@("`@("`@("!S=&0Z.F-O=70@/[EMAIL PROTECTED]<"@I(#P\('-T9#HZ96YD
M;#L**R`@("H@("`@("`@("[EMAIL PROTECTED]&5L971E('!Q+G1O<"@I.PHK("[EMAIL PROTECTED]@("`@
M("`@("!P<2YP;W`H*3L**R`@("H@("`@("!]"BL@("`J("!]"BL@("`J("!<
M96YD8V]D90HK("[EMAIL PROTECTED]("[EMAIL PROTECTED]&5M<&QA=&4\='EP96YA;[EMAIL 
PROTECTED]"!T>7!E
H;F%M92!?4V5Q=65N8V4^"B`@("[EMAIL PROTECTED]
+   *  #include 
+   *  #include 
+   *
+   *  class Int
+   *  {
+   *  public:
+   *  Int(int i)
+   *  : i_(i)
+   *  {
+   *  }
+   *
+   *  int i_;
+   *  };
+   *
+   *  std::ostream &
+   *  operator<< (std::ostream & os, const Int & i)
+   *  {
+   *  return os << i.i_;
+   *  }
+   *
+   *  class Int_less
+   *  {
+   *  public:
+   *  // Function operator
+   *  bool operator() (const Int * i1, const Int * i2)
+   *  {
+   *  return i1->i_ < i2->i_;
+   *  }
+   *  };
+   *
+   *  typedef std::vector< Int * > vector_type;
+   *  typedef std::priority_queue< Int *, vector_type, Int_less >
priority_queue_type;
+   *
+   *  void
+   *  foo()
+   *  {
+   *  vector_type v;
+   *
+   *  v.push_back(new Int(8));
+   *  v.push_back(new Int(1));
+   *  v.push_back(new Int(5));
+   *
+   *  priority_queue_type pq(v.begin(), v.end());
+   *
+   *  while (!pq.empty())
+   *  {
+   *  std::cout << *pq.top() << std::endl;
+   *  delete pq.top();
+   *  pq.pop();
+   *  }
+   *  }
+   *  \endcode
+   */
   template
 class queue
 {


HTH

-- 
   Summary: documentation example for std::priority_queue usage
   Product: gcc
   Version: 3.4.1
Status: UNCONFIRMED
  Severity: enhancement
  Priority: P2
 Component: libstdc++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: Number_42 at caramail dot com
CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: all
  GCC host triplet: all
GCC target triplet: all


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18174


[Bug libstdc++/18174] documentation example for std::priority_queue usage

2004-10-27 Thread Number_42 at caramail dot com

--- Additional Comments From Number_42 at caramail dot com  2004-10-27 12:00 
---

(In reply to comment #1)
> Could you send your patch to gcc-patches@ and [EMAIL PROTECTED]  Also could you make
it off the HEAD (aka 
> 4.0.0)?

I can send it to these mailing lists but i can't download the all gcc CVS, so
not on 4.0.0.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18174