Visual Studio

This post is also available in Italian. As stated in a previous post, final keyword enables the sealing of classes and methods. This is important because it allows interesting compile-time checks, but also enables quite a powerful optimization: the devirtualization. Devirtualization happens when the compiler can statically decide, at compile time, which function should be called, so it can produce …

Continue reading The power of devirtualization

Discussing with another C++ programmer, we came out with this piece of code: #include <iostream> template <class… Args> void foo(int, Args…) {     std::cout << “1”; } template <class…Args> void foo(Args…, int) {     std::cout << “2”; } int main() {     foo(11); // A     foo<>(11); // B     foo(11, 33);                    // C     foo<int>(11, 33);               // D     foo(11, 22, 33);                // E     foo<int, int>(11, 22, 33);      // F } I was pretty convinced that all the calls to foo were ambiguous, so I decided to test it with different …

Continue reading Curiosity #20160225