title: Removing last trailing comma from the arguments of a macro
body: <p>I need to remove the last trailing comma from a list of macro arguments (because they will be eventually expanded into template arguments where the trailing comma is not admitted).</p>
  <p>So I need a macro <code>remove_trailing_comma()</code> which called like <code>remove_trailing_comma(arg1, arg2, arg3, )</code> expands to <code>arg1, arg2, arg3</code>.</p>
  <p>I've tried with different combinations of varargs and <code>__VA_OPT__</code> but I seem to not be able to do it.</p>
  <p>For example:</p>
  <pre><code>#define discard_trailing_comma(arg, ...) \
      arg __VA_OPT__(,) discard_trailing_comma(__VA_ARGS__)
  
  discard_trailing_comma(1, 2, 3, )
  </code></pre>
  <p>does not work (with g++ 10) because expands to <code>1 , discard_trailing_comma(2, 3,)</code>, I do not know why (are macro not expanded recursively?)</p>
  <p>Is this possible in C++20?</p>