Does putting types/functions inside namespace make compiler's parsing work easy?
        Posted  
        
            by 
                iammilind
            
        on Programmers
        
        See other posts from Programmers
        
            or by iammilind
        
        
        
        Published on 2012-10-19T10:26:26Z
        Indexed on 
            2012/10/22
            11:18 UTC
        
        
        Read the original article
        Hit count: 291
        
Retaining the names inside namespace will make compiler work less stressful!?
For example:
// test.cpp
#include</*iostream,vector,string,map*/>
class vec { /* ... */ };
Take 2 scenarios of main():
// scenario-1
using namespace std;  // comment this line for scenario-2
int main ()
{
  vec obj;
}
For scenario-1 where using namespace std;, several type names from namespace std will come into global scope. Thus compiler will have to check against vec if any of the type is colliding with it. If it does then generate error.
In scenario-2 where there is no using namespace, compiler just have to check vec with std, because that's the only symbol in global scope.
I am interested to know that, shouldn't it make the compiler little faster ?
© Programmers or respective owner