Skip to content

Commenting out code #116

@cvvergara

Description

@cvvergara

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions