Std::getline() not necessary in Xcode?

When we got rid of the namespace line, we went through and added std:: to several things, one of which was getline() on Windows. However, in Xcode the getline() command does not have an error, it runs fine without making the change to std::getline(). Since Xcode is happy, can we leave it without the std:: prefix, or will this cause a problem later with Unreal?

It’s not going to be used in Unreal as you would be using Unreal’s API rather than stuff from the C++ Standard Library. That said, you should keep the prefix seeing as that will keep your code compilable on any compiler without needing to modify it.

1 Like

In my version of VS2015 I also did not have to add the std:: to getline actually. I added it in after I saw him do it anyways just to keep things looking neat.

I had the same question ! Cool thing I found a relevant thread.
I added the std:: to getline anyway.

1 Like

Just to expand on this, the reason this isn’t needed is due to “argument dependant lookup” which in a nutshell means that since we passed std::cin as an argument to std::getline means the compiler will look in the std namespace for getline if you didn’t specify that yourself.

3 Likes

@DanM - Thank you for explaining this. I was wondering the same thing!

That cleared up my question. Thanks!

Privacy & Terms