c++ - Literate Coding Vs. std::pair, solutions? -


As most programmers try to adhere to the principles of praise and literacy programming, but in C ++, I regularly use From Std :: pair , for a gazillion common tasks but std :: pair , IMHO is a lowly enemy of literate programming ...

My point is that when I return the code, I have written one or two days ago, and I have a std :: pair (Amatou Watch Jodtop of as) an iterator I "I wonder" what was> the first and second-means other ??? ".

I think others have the same doubts given their code std :: pair , so I was thinking, Better resolution when using the best solution std :: pair ?

struct MyPair: public std :: pair & gt; int, std :: string & gt; {intra & amp; keyInt () {back before;} zero keyIT (consultant and Amp; keyInt) {first = keyInt;} Const std :: string & valueString () {return second;} zero value string (const std :: string and Valuestring) {second = valueString;}};

This is a little verbose, although using it in your code can be a bit easier to read things, for example:

  std :: vector  listPairs; Std :: vector  :: Iterator Iter Peer (listPairs.begin ()); If (iterPair- & Gt; keyInt () == 123) iterPair- gt; value string ("hello");  

Apart from this, I can not see any silver bullet that can make things very clear Is going.


Comments

Popular posts from this blog

c++ - Linux and clipboard -

Visual Studio 2005: How to speed up builds when a VSMDI is open? -

booting ubuntu from usb using virtualbox -