EASTL icon indicating copy to clipboard operation
EASTL copied to clipboard

[Question] Can eastl name space be renamed with standard std name?

Open sergeay opened this issue 3 years ago • 4 comments

Hello everyone,

Looking into your package and I am wondering if the above is doable? I could not find any reference to a similar question - I hope I did not miss. I have done a trivial trial by renaming all eastl appearances in your code by std. Platform is Windows VS2022. Also the build process breaks because of (understandable) name conflicts with Visual Studio std structures and class names. The first conflict came with std::integral_constant defined in type_traits.h in your code and xtr1common in VS2002. Do you guys know any method that let you do that?

The motivation is clear: have existing code that uses std switch to eastl seamlessly. (I know you would say, do the other way around and rename in your code std with eastl: although impossible since that code goes to multiple developers who already have std at home).

Thanks in advance, Serge

sergeay avatar Jan 21 '22 17:01 sergeay

Thats defeats the whole purpose of name spaces. Name space exist with the sole purpose to avoid functions/variables/classes/whatever(s) name collisions.

Developers have std at home? Tell them to use eastd instead of std. They cant change std to eastd? Why? In any case, tell them that using namespace std; in a header/code file is actually a bad practice that, in this specific case, bited...bit them back.

It smells fishy...

MekBoss avatar Jan 26 '22 17:01 MekBoss

I believe placing things inside namespace std is considered undefined behavior in the standard, so unless you're writing a standard library for a particular compiler, you shouldn't do that.

Besides, if you really want to use eastl in place of std, you can use an alias:

namespace std = eastl;

danielytics avatar Feb 22 '22 22:02 danielytics

Thanks Daniel for your feedback,

although eastl is built on top of std, i.e. it uses (on Windows) visual studio and windows kit headers. Those headers finally reach Microsoft's std headers. So having the alias above will cause many duplicates such as vector, map and many others.

sergeay avatar Feb 23 '22 14:02 sergeay

Wouldn't renaming eastl to std cause the same name clashes, though? Perhaps I'm not understanding what you are trying to do.

danielytics avatar Feb 23 '22 23:02 danielytics