title: Replace N-th element of a std::tuple
body: <p>What is the shortest / best way to replace the n-th element of a tuple with a value (which may or may not have a different type)? Solutions including c++20 are fine. 
  [EDIT: I would prefer something not requiring other libraries, but I'm still interested what solutions are possible with e.g. boost].</p>
  
  <p>I.e.:</p>
  
  <pre><code>#include &lt;cassert&gt;
  #include &lt;tuple&gt;
  
  template&lt;std::size_t N, ... &gt;
  auto replace_tuple_element( ... ) // &lt;- Looking for a suitable implementation
  
  struct Foo {
      int value;
  };
  
  int main()
  {
      auto t1  = std::tuple{ 0, 1, 2, 3 };
      auto t2 = replace_tuple_element&lt;2&gt;( t1, Foo{10} );
  
      assert( std::get&lt;0&gt;(t2) == std::get&lt;0&gt;(t1));
      assert( std::get&lt;1&gt;(t2) == std::get&lt;1&gt;(t1));
      assert( std::get&lt;2&gt;(t2).value == 10);
      assert( std::get&lt;3&gt;(t2) == std::get&lt;3&gt;(t1));
  }
  </code></pre>
  
  <p>Note: Just replacing the n-th type in a typelist has e.g. be discussed here: <a href="https://stackoverflow.com/questions/15411022/how-do-i-replace-a-tuple-element-at-compile-time/15412010">How do I replace a tuple element at compile time?</a>. 
  But I also want to replace the value and hope that there are simpler/more elegant solutions now in c++20 than back when that question was asked.</p>