|
You are here |
www.reedbeta.com | ||
| | | | |
playfulprogramming.blogspot.com
|
|
| | | | | The performance of std::visit came up in a discussion, and my first thought was that from reading generated assembly code, it's a jump tabl... | |
| | | | |
mpark.github.io
|
|
| | | | | A visitation mechanism for `std::variant`. | |
| | | | |
eyakubovich.github.io
|
|
| | | | | It's a simple task - you want iterate over all the lines in a file and perform an action on each one. In Python it's as simple as:for line in open("somefile.txt"): print lineHow about C++11. How hard can it be? This stackoverflow post gives us a starting point. We... | |
| | | | |
quuxplusone.github.io
|
|
| | | Consider the following example of an "STL-style algorithm," taken from a lab exercise in one of my training courses: template<class It> bool is_palindrome(It first, It last) { while (first != last) { -last; if (first == last) break; if (*first != *last) { return false; } ++first; } return true; } A palindrome is equal to itself when read forwards or backwards, so, I said blithely, we could rewrite it like this: template<class It> bool is_palindrome(It first, It last) { return std::equal( first, last, std::reverse_iterator(last), std::reverse_iterator(first) ); } But look out - this code has a bug that causes undefined behavior! Do you see it? | ||