Unsafe, `noexcept` and no-overhead way of accessing `std::variant` : <p><a href="http://en.cppreference.com/w/cpp/utility/variant" rel="noreferrer"><code>std::variant</code></a> provides the following access functions:</p>

<ul>
<li><p><a href="http://en.cppreference.com/w/cpp/utility/variant/get_if" rel="noreferrer"><code>std::get_if</code></a>: take <em>pointer</em> to <code>variant</code>, return <em>pointer</em> to alternative. </p>

<pre><code>template &lt;std::size_t I, typename... Ts&gt; 
auto* std::get_if(std::variant&lt;Ts...&gt;* pv) noexcept;
</code></pre>

<ul>
<li><blockquote>
  <p>If <code>pv</code> is not a null pointer and <code>pv-&gt;index() == I</code>, returns a pointer to the value stored in the variant pointed to by <code>pv</code>. Otherwise, returns a null pointer value.</p>
</blockquote>

<p>This means that <code>get_if</code>'s implementation roughly looks like this:</p>

<pre><code>template &lt;std::size_t I, typename... Ts&gt; 
auto* std::get_if(std::variant&lt;Ts...&gt;* pv) noexcept
{
    if(pv == nullptr) return nullptr;
    if(pv-&gt;index() != I) return nullptr;
    return &amp;(pv-&gt;real_get&lt;I&gt;());
}
</code></pre></li>
</ul></li>
<li><p><a href="http://en.cppreference.com/w/cpp/utility/variant/get" rel="noreferrer"><code>std::get</code></a>: take <em>reference</em> to <code>variant</code>, return <em>reference</em> to alternative, <em><code>throw</code></em> on invalid access.</p>

<pre><code>template &lt;std::size_t I, typename... Ts&gt;
auto&amp; std::get(std::variant&lt;Ts...&gt;&amp; v);
</code></pre>

<ul>
<li><blockquote>
  <p>If <code>v.index() == I</code>, returns a reference to the value stored in <code>v</code>. Otherwise, throws <code>std::bad_variant_access</code>.</p>
</blockquote>

<p>This means that <code>get</code>'s implementation roughly looks like this:</p>

<pre><code>template &lt;std::size_t I, typename... Ts&gt; 
auto&amp; std::get(std::variant&lt;Ts...&gt;&amp; v)
{
    if(v.index() != I) throw std::bad_variant_access{};
    return v.real_get&lt;I&gt;();
}
</code></pre></li>
</ul></li>
</ul>

<hr>

<p><strong>I want an unsafe access function that:</strong></p>

<ul>
<li><p>Is <code>noexcept</code>.</p></li>
<li><p>Takes a <em>reference</em> to a <code>variant</code>, avoiding any <code>pv == nullptr</code> check.</p></li>
<li><p>Has <em>undefined behavior</em> if <code>v.index() != I</code>.</p></li>
</ul>

<p>Why? Because there may be some situations where I am 100% sure that a particular <code>variant</code> instance contains a specific type in a code path. Also, it would be useful when writing generic code that already separately checked <code>v.index() != I</code> <em>(e.g. writing my own <code>visit</code>)</em>.</p>

<p>Example implementation:</p>

<pre><code>template &lt;std::size_t I, typename... Ts&gt; 
auto&amp; unsafe_get(std::variant&lt;Ts...&gt;&amp; v)
{
    return v.real_get&lt;I&gt;();
}
</code></pre>

<p><strong>Is there something like this in the standard?</strong> I couldn't find it. If not, <strong>is this possible to implement for <code>std::variant</code>, or do I need to roll out my own <code>variant</code> implementation?</strong></p>
