title: Understanding std::apply inside std::visit
body: <p><a href="https://github.com/google/oboe/blob/e3e93e307456a388a84a6e0d96f9adb240f5918d/apps/fxlab/app/src/main/cpp/native-lib.cpp#L93" rel="nofollow noreferrer">https://github.com/google/oboe/blob/e3e93e307456a388a84a6e0d96f9adb240f5918d/apps/fxlab/app/src/main/cpp/native-lib.cpp#L93</a></p>
  <pre><code>std::visit([id](auto &amp;&amp;stack) {
      std::function&lt;void(decltype(stack.getType()), decltype(stack.getType()))&gt; f;
      int i = 0;
      std::apply([id, &amp;f, &amp;i](auto &amp;&amp;... args) mutable {
          ((f = (i++ == id) ?
                args.template buildDefaultEffect&lt;decltype(stack.getType())&gt;() : f), ...);
      }, EffectsTuple);
      stack.addEffect(std::move(f));
  }, enginePtr-&gt;functionList);
  </code></pre>
  <p>std::visit applies the lambda to the vector <code>functionList</code>. The lambda, applies the lambda inside of it to the <code>EffectsTuple</code>.</p>
  <p>However, I'm having a hard time understanding</p>
  <pre><code>((f = (i++ == id) ?
                args.template buildDefaultEffect&lt;decltype(stack.getType())&gt;() : f), ...);
  </code></pre>
  <p>What does the outer most <code>()</code> does? what is the second argument <code>...</code>? What does <code>args.template</code> mean?</p>