title: How to fix this deprecated use of std::allocator?
body: <p>Here are the key points:</p>
  <p>1: This project uses the open-source repository <a href="https://github.com/lighttransport/nanort/blob/master/nanort.h" rel="nofollow noreferrer">NanoRT</a> as a raytracer in a project.</p>
  <p>2: This project is compiled under Visual Studio 2019 (C++17)</p>
  <p>3: This project is compiled with warnings treated as errors (and this cannot be changed). Adding the define to suppress these warnings did not help.</p>
  <p>However, it looks like part of this code does not work in C++17, as it uses something that has become deprecated: (line 133 and 134 in the link I provided)</p>
  <pre><code>  typedef typename std::allocator&lt;T&gt;::pointer pointer;
    typedef typename std::allocator&lt;T&gt;::size_type size_type;
  </code></pre>
  <p>I need to figure out how to approach fixing this. The error suggests using <code>std::allocator_traits</code> but I am really unfamiliar with this use of <code>std::allocator</code> or <code>allocator_traits</code>.</p>
  <p>Looking at the source, is this a few-line fix, or is this much more complicated than that and would require restructuring large portions of the code?</p>
  <p>It looks like <code>pointer</code> is used as the return for <code>allocate()</code> and the first argument to <code>deallocate()</code>, with <code>size_type</code> being used in the same way.</p>
  <pre><code>  // Actually do the allocation. Use the stack buffer if nobody has used it yet
    // and the size requested fits. Otherwise, fall through to the standard
    // allocator.
    pointer allocate(size_type n, void *hint = 0) {
      if (source_ != NULL &amp;&amp; !source_-&gt;used_stack_buffer_ &amp;&amp;
          n &lt;= stack_capacity) {
        source_-&gt;used_stack_buffer_ = true;
        return source_-&gt;stack_buffer();
      } else {
        return std::allocator&lt;T&gt;::allocate(n, hint);
      }
    }
  
    // Free: when trying to free the stack buffer, just mark it as free. For
    // non-stack-buffer pointers, just fall though to the standard allocator.
    void deallocate(pointer p, size_type n) {
      if (source_ != NULL &amp;&amp; p == source_-&gt;stack_buffer())
        source_-&gt;used_stack_buffer_ = false;
      else
        std::allocator&lt;T&gt;::deallocate(p, n);
    }
  </code></pre>