title: In which fundamental data type can I store an address
body: <p>I want to store a pointer into a fundamental data type.</p>
  <p>My intuition says that the right data type for this is a <code>std::size_t</code> and it works:</p>
  <pre class="lang-cpp prettyprint-override"><code>#include &lt;fmt/core.h&gt;
  
  int main() {
    int i = 0;
    int* p = &amp;i;
    auto const t = reinterpret_cast&lt;std::size_t&gt;(p);
    fmt::print(&quot;size of address: {}\n&quot;, sizeof(p));
    fmt::print(&quot;size of std::size_t: {}\n&quot;, sizeof(t));
    fmt::print(&quot;value of address to i: {}\n&quot;, static_cast&lt;void*&gt;(p));
    fmt::print(&quot;value of std::size_t t: {0:#x}\n&quot;, t);
    return *p;
  }
  
  </code></pre>
  <p><a href="https://godbolt.org/z/dWf5W6" rel="nofollow noreferrer">https://godbolt.org/z/dWf5W6</a></p>
  <p>And the program outputs:</p>
  <pre><code>Program returned: 0
  size of address: 8
  size of std::size_t: 8
  value of address to i: 0x7ffdd754a0dc
  value of std::size_t t: 0x7ffdd754a0dc
  </code></pre>
  <p>But is this true for every platform?</p>
  <p>How can I be sure?</p>