Van's House

I'm a developer at C++ team. I'm interested in everything related to C++

Browse by Tags

Tagged Content List
  • Blog Post: C++98 -> C++11: Pass by value or pass by reference?

    In GoingNative 2012 , there are some discussions on the new coding style for C++11. One interesting thing which is mentioned by Bjarne Stroustrup, Stephan T. Lavavej and Herb Sutter is the most efficient way to pass the argument. In C++98, pass by reference is in general more efficient because it...
  • Blog Post: Speed up iostream

    Throughput of iostream is considered much slower compared with its C counterpart. For example: printf( "1234567\n" ); cout << "1234567" << endl; If you iterate 10 5 times, printf takes about 50ms while cout takes >1s. This looks quite annoying. After digging into the source...
  • Blog Post: Detect Shift Overflow

    This is an intellectual exercise: when shifts a 32-bit unsigned integer in C++, how to detect whether the calculation overflows efficiently? Here is the function prototype. shl_overflow will return true if v << cl overflows (cl is between 0 and 31. And we assume that sizeof(unsigned long) =...
  • Blog Post: Optimize Your Code: Matrix Multiplication

    Matrix multiplication is common and the algorithm is easy to implementation. Here is one example: Version 1: template < typename T> void SeqMatrixMult1( int size, T** m1, T** m2, T** result) { for ( int i = 0; i < size; i++) { for ( int j = 0; j < size; j++) { result[i][j] = 0; for ( int...
  • Blog Post: Magic behind ValueType.Equals

    In "Effective C#", Bill Wagner says "Always create an override of ValueType.Equals() whenever you create a value type". His main consideration is the performance, because reflection is needed to compare two value types memberwisely. In fact, the framework provides optimization for "simple" value type...
Page 1 of 1 (5 items)