2

After encountering many questions of why not to use namespaces like std and reading documentations I had this idea so I didn't have to type std:: everytime.

namespace leanandmean
{
 using std::cout; 
 using std::endl;
 using std::map;
}

using namespace leanandmean;

So I'd only use the methods I need from the libraries and namespace. I've been wondering about possible mistakes it could lead to, so the final question is if using such method is totally ok?

3
  • +1!!! This will save a lot of work, excelent idea Jul 18, 2012 at 23:30
  • 3
    Do you really think that typing "std::" represents any significant amount of work compared to the total software development effort required to create good high quality software? The approach suggested does nothing but obfuscate the code and will result in the authors name being taken in vain by other developers for many years into the future!
    – Ozraptor
    Jul 18, 2012 at 23:34
  • Note that you will have to save typing std:: at least 25 times for this to be a net gain in file size. How much do you want to work to potentially save some work? (A typing class could be a better investment :-)
    – Bo Persson
    Jul 19, 2012 at 7:48

1 Answer 1

0

Method is ok, if you don't use it in header files and may be in global namespace in .cpp files...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.