C++ ‘typedef’ vs. ‘using … = …’ [duplicate]

They are the same. To quote the C++11 standard (or the draft to be specific): A typedef-name can also be introduced by an alias-declaration. The identifier following the using keyword becomes a typedef-name and the optional attribute-specifier-seq following the identifier appertains to that typedef-name. It has the same semantics as if it were introduced by … Read more

Why does C++’s “using namespace” work the way it does?

Quoting an excerpt from C++ Primer (5th Edition) section “18.2.2. Using Namespace Members” The scope of names introduced by a using directive is more complicated than the scope of names in using declarations. As we’ve seen, a using declaration puts the name in the same scope as that of the using declaration itself. It is … Read more

C++: Should I use ‘typedef’ or ‘using namespace’? [closed]

The two options you state are not equivalent. This one: using namespace project1::namespace1; pulls in everything from the namespace, giving you little control and making clashes likely. I see only cons, and no pros here. But you don’t need to use a typedef to bring in a single symbol, you can use using project1::namespace1::class1; Whether … Read more

Why doesn’t a using-declaration work to solve the diamond problem?

Someone else can find the standard quote but I’m going to explain conceptually. It doesn’t work because a using-declaration only affects name lookup. Your using-declaration causes name lookup to succeed where it would otherwise fail, that is, it tells the compiler where to find the function f. But it does not tell it which A … Read more

Visual Studio or Resharper functionality for placement of using directives

UPDATE – ReSharper 2016.1: This option is now moved to Code Editing → C# → Code Style → Add ‘using’ directive to the deepest scope Have you tried the ReSharper option: Languages → C# → Formatting Style → Namespace Imports → Add using directive to the deepest scope I’m not sure whether R#’s code cleanup … Read more

The type or namespace name could not be found [duplicate]

See this question. Turns out this was a client profiling issue. PrjForm was set to “.Net Framework 4 Client Profile” I changed it to “.Net Framework 4”, and now I have a successful build. Thanks everyone! I guess it figures that after all that time spent searching online, I find the solution minutes after posting, … Read more

error code: 521