It seems that nullptr is declared in the default global namespace. Wouldn't it make sense for it to be in the std namespace?
            Asked
            
        
        
            Active
            
        
            Viewed 4,408 times
        
    36
            
            
         
    
    
        Peter Mortensen
        
- 30,738
- 21
- 105
- 131
 
    
    
        MWB
        
- 11,740
- 6
- 46
- 91
- 
                    16Considering it is supposed to be used instead of null, reducing the required typing can only encourage its use. – Dave Feb 02 '14 at 11:41
2 Answers
76
            nullptr is a C++11 keyword (no different to if, public, true, void, etc.), so namespaces don't apply.
 
    
    
        Oliver Charlesworth
        
- 267,707
- 33
- 569
- 680
- 
                    45
- 
                    1I think he said it just right. The `true`/`false` analogy isn't helpful for someone coming from a C background, as `true`/`false` in C are just macros defined in [stdbool.h](http://cplusplus.com/reference/cstdbool/) which do something like `#define true 1` and `#define false 0`. So, are you saying `nullptr` is a macro? Is it an integer, like C's `true`/`false`? Is it just a zero (`0`)?--that would kind of defeat the whole purpose of `nullptr`, now, so that analogy to C++'s `true`/`false` really really muddles things up. – Gabriel Staples Aug 20 '20 at 23:38
29
            
            
        nullptr is a pointer literal the same way as for example true is a boolean literal. This literal has type std::nullptr_t that is as you see this type is defined in name space std:: The pointer literal is described in section 2.14.7 Pointer literals of the C++ Standard.
 
    
    
        lornova
        
- 6,667
- 9
- 47
- 74
 
    
    
        Vlad from Moscow
        
- 301,070
- 26
- 186
- 335