C++ Insights – See your source code with the eyes of a Compiler
Thread
Unofficial Hacker News client; not affiliated with Y Combinator.
C++ Insights – See your source code with the eyes of a Compiler
Unofficial Hacker News client; not affiliated with Y Combinator.
StilesCrisis · · focus · HN ↗
sltkr · · focus · HN ↗
Here's an example: <a href="https://cppinsights.io/s/f04b6896" rel="nofollow">https://cppinsights.io/s/f04b6896
(That also shows how C++'s range-based for-loops work, which is similarly some syntactic suger for a fairly mundane for-loop, but details are interesting: unlike a typical for-loop, the loop variable is declared inside the loop body.)
StilesCrisis · · focus · HN ↗
frabert · · focus · HN ↗
Someone · · focus · HN ↗
That’s not true in C++, is it? There, this does not compile
(<a href="https://cppinsights.io/s/26405687" rel="nofollow">https://cppinsights.io/s/26405687: error: use of undeclared identifier 'i')<a href="https://en.cppreference.com/cpp/language/for" rel="nofollow">https://en.cppreference.com/cpp/language/for:
“A for statement equivalent to:
Except that […]”and
“While in C names declared in the scope of init-statement and condition can be shadowed in the scope of statement, it is forbidden in C++:
“