Re: std::pair<,>

From: Mike Wahler (mkwahler_at_mkwahler.net)
Date: 10/04/03


Date: Fri, 03 Oct 2003 22:05:39 GMT


"David Rubin" <bogus_address@nomail.com> wrote in message
news:3F7DF018.9637D997@nomail.com...
> Mike Wahler wrote:
>
> > > I wonder if there is a way to create a pair class
> > > using std::pair but typedef its first and second
> > > to x and y using C++.
> [snip]
> > >The only way I can think
> > > of is to subclass std::pair<,>.
> >
> > IMO no reason to.
> >
> > std::pair<T,T>(x,y);
>
> The question is, is a Point a pair? From the description of pair, it
> seems like the answer is yes.

Agreed.

> So, if you want a Point with members x and
> y, why not subclass?

Why not simply:

std::pair<int,int> coord(x,y);

or if you like:

typedef std::pair<int,int> Point;

Point coord(x,y);

??

-Mike



Relevant Pages

  • Re: std::pair<,>
    ... Mike Wahler wrote: ... > IMO no reason to. ...
    (comp.lang.cpp)
  • Re: OT - So Michael...
    ... The biggest mistake made, IMO, was to ... If establishing a democracy wasn't part of the original plan then ... separation of religion from government. ... but they are there for a reason. ...
    (rec.autos.makers.ford.mustang)
  • Re: OT - So Michael...
    ... The biggest mistake made, IMO, was to ... If establishing a democracy wasn't part of the original plan then ... separation of religion from government. ... but they are there for a reason. ...
    (rec.autos.makers.ford.mustang)
  • Re: OT Dodges New Super Bee
    ... the reason Chrysler had to give it all that ... It is also, IMO, the main ... reason it is a good solid car. ... I have no doubt it is a nice car. ...
    (rec.autos.makers.ford.mustang)
  • Re: Armstrong, Crowe split
    ... made, IMO, a good decision. ... You don't seem to believe anything else Lance says, ... I have no reason not to beleive that they're seperated. ... blame a man for where his penis goes than you can blame a compass for ...
    (rec.bicycles.racing)