Skip to content
  • Mike Fleetwood's avatar
    C++11: Convert NULL to nullptr (!117) · 40665913
    Mike Fleetwood authored and Curtis Gedak's avatar Curtis Gedak committed
    In C++11, nullptr [1] is the strongly typed value to use instead of the
    macro NULL [2].  Use everywhere [3][4].
    
    [1] nullptr, the pointer literal (since C++11)
        https://en.cppreference.com/w/cpp/language/nullptr
    [2] NULL
        https://en.cppreference.com/w/cpp/types/NULL
    [3] Bjarne Stroustrup's C++ Style and Technique FAQ, Should I use NULL
        or 0?
        https://www.stroustrup.com/bs_faq2.html#null
            "In C++, the definition of NULL is 0, so there is only an
            aesthetic difference.  I prefer to avoid macros, so I use 0.
            Another problem with NULL is that people sometimes mistakenly
            believe that it is different from 0 and/or not an integer.  In
            pre-standard code, NULL was/is sometimes defined to something
            unsuitable and therefore had/has to be avoided.  That's less
            common these days.
    
            If you have to name the null pointer, call it nullptr; that's
            what it's called in C++11.  Then, "nullptr" will be a keyword.
            "
    [4] What is nullptr in C++? Advantages, Use Cases & Examples
        https://favtutor.com/blogs/nullptr-cpp
            "Advantages of nullptr
            ...
            Compatible: Null pointers are compatible with null pointer
            constants in the C style (such as NULL and 0).  This implies
            that old C code that uses these constants and null pointers can
            communicate with each other in C++.
            "
    
    Closes !117 - Require C++11 compilation
    40665913