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: Debug vs Release - v2

    Four and half a year ago (how time flies), I wrote a post about the potential issues mixing debug and release CRT in the same program. At the end, it says, 'It's fortunate that this is a linker error. Otherwise, you'll waste lots of time in debugging to find out the subtle incompatibility'. Today...
  • Blog Post: Connect Bugs that I Fixed

    Similar to STL's post on vcblog , I generate a table of connect bugs that I have fixed after I officially worked on the compiler front end: Connect ID Title 581680 Lambda declaration cannot access closure variables when defined as a member function of an inline class ...
  • Blog Post: November CTP of Visual C++ compiler, more C++11 features

    Our team announced Novemeber CTP of Visual C++ compiler . It contains the following C++11 features besides those already in VS2012: Variadic templates Uniform initialization and initializer_lists Delegating constructors Raw string literals Explicit conversion operators Default...
  • Blog Post: C++: Under the Hood

    This is an article written by Jan Gray. It is quite old, but most of the contents still apply today. The original article on MSDN can no longer be found. Here is the pdf version on OpenRCE: http://www.openrce.org/articles/files/jangrayhood.pdf . Overview: How are classes laid out? How are data members...
  • 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: Protected or Private II

    Someone reminds me that it has been nearly 2 years since my last blog post. How time flies! Many things happened during this period. I moved to Redmond and I’m now officially working on C++ compiler. The work is busy and also challenging. Recently, there was a thread in our internal discussion...
  • Blog Post: C++0x features in VC2010 - nullptr

    Summary Page ( n3090.pdf is the current working draft of C++0x standard, it is available at http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2010/n3090.pdf ) What we have before C++0x Everyone knows that null pointer value is NULL. In C++, NULL is defined as follows: #define NULL...
  • Blog Post: C++0x features in VC2010 - some decltype bugs

    1. decltype(*&function) https://connect.microsoft.com/VisualStudio/feedback/details/510640 int foo(); decltype (*&foo) df; // it should be "int (&)()", but it is "int (*)()" The internal representation (it is special for "*&function") doesn’t contain the enough information...
  • Blog Post: C++0x features in VC2010 - decltype

    Summary Page ( n3090.pdf is the current working draft of C++0x standard, it is available at http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2010/n3090.pdf ) What we have before C++0x When do generic programming in C++, you often have to generate type from template parameters. Type traits...
  • Blog Post: C++0x features in VC2010 - auto

    Summary Page ( n3090.pdf is the current working draft of C++0x standard, it is available at http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2010/n3090.pdf ) What we have before C++0x C++ is a strongly typed programming language. You have to specify the type when declaring variables. Sometimes...
  • Blog Post: C++0x features in VC2010 - static_assert

    Summary Page ( n3090.pdf is the current working draft of C++0x standard, it is available at http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2010/n3090.pdf ) What we have before C++0x It is a common task to output meaningful error message from source code based on compile-time conditions...
  • Blog Post: C++0x features in VC2010 - Summary

    VC2010 has been released for a while. It adds many C++0x features (The complete list can be found here: C++0x Core Language Features In VC10: The Table ) In the following posts, I’d like to share some of my experience of these new features. They will cover: What we have before C++0x What...
  • Blog Post: VC's "evil" extension: Pre-definition of basic types

    In VC, you may find that you can use "size_t" directly without including any headers. size_t i = 0; int main() { atexit(0); } However, "size_t" is not a built-in type. It is a typedef in <stddef.h>. So what's the magic? In VC compiler, it will include some internal headers for various reasons...
  • Blog Post: VC's "evil" extension: Implicit definition of static constant member

    C++ supports in-class initialization of static integral constant members. It is nearly the same as enum, with the following difference (quoted from C++03 9.4.2.4 ([class.static.data])): The member shall still be defined in a namespace scope if it is used in the program and the namespace scope definition...
  • Blog Post: VC's "evil" extension: $

    In C++, only a few characters can be used as part of the identifier. identifier: identifier-nondigit identifier identifier-nondigit identifier digit identifier-nondigit: nondigit universal-character-name other implementation-defined characters nondigit: one of a b c d e f g h i j k l m n o p q r s...
  • Blog Post: Inline or Not Inline

    What is inline? This keyword is mainly used to ask the compiler to inline substitution of the function body at the point of call. Like 'register', this is only a suggestion to the compiler. Modern compiler can handle inlining using advanced heuristic to get better size / performance balance without the...
  • 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: Recursive Algorithm in C++

    Many recursive algorithms have initial parameters. For example, Fibonacci Number is defined as: Fn = Fn-1 + Fn-2, with F1 = F2 = 1. By giving different values to F1 and F2, we can generate different sequence of numbers. 1. If we implement the algorithm using functions, we have to either define...
  • Blog Post: Measure Initialization Time of Global Variables

    NOTICE: The technique describes in the article may not be supported in future release of VC. You should not use it in production code There are two kinds of initialization in C++: static initialization and dynamic initialization. According to the standard, static initialization shall always be...
  • 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: C++ Template Trick: Detecting Object Slicing

    Object slicing often happens when you pass the object by value. Compiler will do implicitly conversion from derived to base for you without any warning message. If you want to detect object slicing, you're on your own. However, template can help you. Because object slicing will call copy constructor...
  • Blog Post: C++ Template Trick: Detecting the Existence of Class Member at Compile Time

    C++0x will provide a full set of type traits helpers to ease generic programming. However, there is no support for the detection of class members. The general problem is hard. Here we will try to tackle the more specific version: detecting the class member with given name and type. In C++, function...
  • Blog Post: Standard library changes in C++0x

    C++0x will be released in the near future. Do you know the changes of standard library? Here is a list of changes that I've collected (minor behavior changes and changes related to concepts are not included). 1. New stuff system_error: new header array, vector, deque, list, string, map, set, unordered_map...
  • Blog Post: VC extensions list

    MSDN has a page describing various VC extensions. But it is far from complete. I've collected a list of nonstandard extensions provided by VC, some of them are evil . If you want to write standard conformant C++ code, you'd better be aware of these extensions which are on by default. Some commonly...
Page 1 of 2 (32 items) 12