title: Is it possible to place a macro in a namespace in c++?
body: <p>My application uses another output than the standard output for logging information, which is why I wrote my own <code>Log()</code>, <code>Error()</code>, <code>Panic()</code> and <code>Assert()</code> functions. To organize things nicely, I enclose all the debugging stuff in a <code>Debug</code> namespace.</p>
  
  <p>It would make more sense for the <code>Assert()</code> function to also provide a source file and line number, which is only possible using the <code>__LINE__</code> and <code>__FILE__</code> macros. However, it is pretty unpleasant, inefficient etc... to always have to specify these two parameters.</p>
  
  <p>So this is how my code would look like:</p>
  
  <pre><code>namespace Debug {
     void Assert (int condition, std::string message, std::string file, int line);
  }
  </code></pre>
  
  <p>My question is, is it possible to place a macro which includes those two parameters inside the <code>Debug</code> namespace? Like this:</p>
  
  <pre><code>namespace Debug {
     void Assert_ (int condition, std::string message, std::string file, int line);
     #define Assert(a,b) Assert_(a, b, __FILE__, __LINE__)
  }
  
  // .... Somewhere where I call the function ....
  Debug::Assert (some_condition, "Some_condition should be true");
  
  // Output: Assertion failed on line 10 in file test.cpp:
  //           Some_condition should be true
  </code></pre>
  
  <p>Is this valid c++? If not, is there any way of making this work?</p>