Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove using namespace std from header files #156

Closed
juanangp opened this issue Mar 16, 2022 · 4 comments · Fixed by #168
Closed

Remove using namespace std from header files #156

juanangp opened this issue Mar 16, 2022 · 4 comments · Fixed by #168
Assignees

Comments

@juanangp
Copy link
Member

Several instances to using namespace std are found in several header files, which is considered bad coding practise:
https://stackoverflow.com/questions/1452721/why-is-using-namespace-std-considered-bad-practice

Here a list of the header files where I have found using namespace std in the code:

./source/framework/core/inc/TRestTask.h
./source/framework/tools/inc/TRestStringHelper.h
./source/framework/tools/inc/TRestSystemOfUnits.h
./source/framework/tools/inc/TRestDataBase.h
./source/framework/tools/inc/TRestPhysics.h
./source/framework/tools/inc/TRestReflector.h
./source/framework/tools/inc/TRestStringOutput.h
./source/framework/tools/inc/TRestTools.h
./source/packages/restG4/include/PhysicsList.h
./source/packages/restG4/include/EventAction.h
./source/packages/restG4/include/SteppingAction.h
./source/packages/restG4/include/RunAction.h
./source/packages/restG4/include/PrimaryGeneratorAction.h

However the required changes in the code could be larger than these header files, as has been pointed in #124 for TRestAnalysisPlot.h

I am willing to give a hand on this issue, but I think we should divide the work because the load can be large.

@lobis
Copy link
Member

lobis commented Mar 17, 2022

I think its enough that when you work on some file, we try to also remove these kind of things in the same PR. We just need everyone to keep these things in mind!

@jgalan
Copy link
Member

jgalan commented Mar 17, 2022

It could probably achieved quickly by find and replace any ----cout << by ---std::cout
where ---- are 4-white spaces in front

Then find and replace << endl; by << std::endl; any -string by -std::string, etc.

This could be done only at header files. Since we can still do using namespace std; at cxx.

https://stackoverflow.com/questions/11392478/how-to-replace-a-string-in-multiple-files-in-linux-command-line

@juanangp
Copy link
Member Author

In fact we should also replace many others such as string vector map . Also, we should cross check the function args. We should also check if using namespace std is defined in the source files, perhaps is missing in the classes which are defined in the header.

On the other hand, I prefer to do these changes in a separate PR rather than in other PR that are not connected with this issue.

@lobis
Copy link
Member

lobis commented Mar 27, 2022

restG4 using namespace std; and other minor stuff was fixed on rest-for-physics/restG4#35.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants