Dwight's blog
c++ : don’t use pair<>

I’m sure I’ll get some argument on this, but don’t use pair<>.  Except when you are using something already requiring it, such as stl classes and stl algorithms.

Instead of pair<A,B>, why not

struct X {
  A a;
  B b;
};

The above might not look so different but how about pair<int,int> versus

struct Point {
 int x, y;
};

More descriptive.  Templates become more difficult, thus pair<> being there in the first place, but often one doesn’t need such a level of generics in an app.  So take the better readability.

  1. dmerr posted this
blog comments powered by Disqus

document.getElementById('tumblr_controls').allowTransparency=true;

Quantcast