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

Commenting out code #116

Open
cvvergara opened this issue Jul 27, 2020 · 0 comments
Open

Commenting out code #116

cvvergara opened this issue Jul 27, 2020 · 0 comments
Labels

Comments

@cvvergara
Copy link
Member

Suppose you have this code

template <typename B_G>
         void back_edge(E e, const B_G&) {
             log << "back edge " << e << "\t\t : id " << m_graph[e].id << " ("
                 << m_graph[m_graph.source(e)].id << ", " << m_graph[m_graph.target(e)].id << ")" << "\n";
         }

and you want to comment out the body of the function to skip the log, and maybe in the future uncomment it, and comment it back again

template <typename B_G>
         void back_edge(E e, const B_G&) {
#if 0
             log << "back edge " << e << "\t\t : id " << m_graph[e].id << " ("
                 << m_graph[m_graph.source(e)].id << ", " << m_graph[m_graph.target(e)].id << ")" << "\n";
#endif
         }

never ever use //:

template <typename B_G>
         void back_edge(E e, const B_G&) {
             // log << "back edge " << e << "\t\t : id " << m_graph[e].id << " ("
             //    << m_graph[m_graph.source(e)].id << ", " << m_graph[m_graph.target(e)].id << ")" << "\n";
         }

Never ever use `/* */:

template <typename B_G>
         void back_edge(E e, const B_G&) {
/*
             log << "back edge " << e << "\t\t : id " << m_graph[e].id << " ("
                 << m_graph[m_graph.source(e)].id << ", " << m_graph[m_graph.target(e)].id << ")" << "\n";
*/
         }

With the proper way of commenting out the code, if you want the code back again you just change the 0 to 1:

#if 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant