Author Topic: Generic Programming  (Read 2006 times)

0 Members and 1 Guest are viewing this topic.

Ibra

  • Philosopher of the Void
  • Posts: 132
Re: Generic Programming
« Reply #15 on: April 22, 2020, 01:23:24 am »
Thanks Hentrich and Holden,

I am good so far. I hope you are safe too. 

I left my work on January. I worked at night shift for 8 years or more and that deteriorated my health considerably but I didn't mind that, on last December i was ordered by the masters to go into the day shift, I had argument every day with ass-kissing managers  and then i left . well "Hell is the other people" as Sartre? said.

I already missed the Syrian war train, I hope I can ride Corona train to the graveyard. I am already at my wit's end.

 I downloaded "C++ tour 2nd edition" book and I am fiddling with GCC compiler(MinGW-64) as time passing activity, at least we have some control about bits and bytes.

Quote from: Hentrich
After you fill the vector with pairs of {int, string}, you can access as follows:

int count = 0;
for (const auto& [i, s] : pairs) {
    ++count;
    std::cout << "Pair #" << count << ": The integer is " << i << ", and the string is " << s << '\n';
}

Without that, you could just as easily write:

int count = 0;
for (const auto& p : pairs) {
    ++count;
    std::cout << "Pair #" << count << ": The integer is " << p.first << ", and the string is " << p.second << '\n';
}

That is neat trick, reminds me of python unpacking techniques.

take care,
Suffering is the only fruit of human race