title: How do I correctly pass converting constructor from an std::queue through to the underlying std::deque?
body: <p>I have created a custom memory allocator. To use it with STL Containers, I've also created a wrapper so that it adheres to the <code>std::allocator_traits</code> requirements.</p>
  <pre><code>#include &lt;cstdint&gt;
  #include &lt;memory&gt;
  #include &lt;deque&gt;
  #include &lt;queue&gt;
  
  class CustomAlloc
  {
  public:
      CustomAlloc(const std::size_t&amp; maxMem) noexcept
      :
          m_maxMem(maxMem),
          m_usedMem(0)
      {
  
      }
  
      CustomAlloc(CustomAlloc&amp;&amp; other) noexcept
      :
          m_maxMem(other.m_maxMem),
          m_usedMem(other.m_usedMem)
      {
  
      }
  
      CustomAlloc&amp; operator=(CustomAlloc&amp;&amp; other) noexcept
      {
          m_maxMem = other.m_maxMem;
          m_usedMem = other.m_usedMem;
          return *this;
      }
  
      CustomAlloc(const CustomAlloc&amp;) = delete;
      CustomAlloc&amp; operator=(CustomAlloc&amp;) = delete;
  
      [[nodiscard]] void* Allocate(const std::size_t&amp; size)
      {
          if(m_usedMem + size &gt; m_maxMem)
          {
              throw std::bad_alloc();
          }
  
          void* ptr = std::malloc(size);
  
          if(ptr == nullptr)
          {
              throw std::bad_alloc();
          }
  
          m_usedMem += size;
  
          return ptr;
      }
  
      void Free(void* const ptr) const
      {
          return std::free(ptr);
      }
  
      const std::size_t&amp; GetMaxMem() const noexcept
      {
          return m_maxMem;
      }
  
  private:
      std::size_t m_maxMem;
      std::size_t m_usedMem;
  };
  
  template&lt;typename T, typename Alloc&gt;
  class STLAdaptor
  {
  public:
  
      typedef T value_type;
  
      STLAdaptor(Alloc&amp; allocator) noexcept
      :
          m_allocator(allocator)
      {
  
      }
  
      template&lt;typename U&gt;
      STLAdaptor(const STLAdaptor&lt;U, Alloc&gt;&amp; other) noexcept
      :
          m_allocator(other.m_allocator)
      {}
  
      [[nodiscard]] constexpr T* allocate(std::size_t n)
      {
          return reinterpret_cast&lt;T*&gt;
              (m_allocator.Allocate(n * sizeof(T)));
      }
  
      constexpr void deallocate(T* p, [[maybe_unused]] std::size_t n)
      {
          m_allocator.Free(p);
      }
  
      std::size_t MaxAllocationSize() const
      {
          return m_allocator.GetMaxMem();
      }
  
      bool operator==(const STLAdaptor&lt;T,Alloc&gt;&amp; rhs)
      {
          return m_allocator.GetStart() == rhs.m_allocator.GetStart();
      }
  
      bool operator!=(const STLAdaptor&lt;T,Alloc&gt;&amp; rhs)
      {
          return !(*this == rhs);
      }
  
      Alloc&amp; m_allocator;
  };
  
  template&lt;typename T, typename Alloc&gt;
  using CustomDeque = std::deque&lt;T, STLAdaptor&lt;T,Alloc&gt;&gt;;
  
  template&lt;typename T, typename Alloc&gt;
  using CustomQueue = std::queue&lt;T, CustomDeque&lt;T, Alloc&gt;&gt;;
  </code></pre>
  <p>The issue I'm facing:</p>
  <pre><code>int main()
  {
      CustomAlloc customAlloc(3000000);
  
      CustomDeque&lt;int, CustomAlloc&gt; customDeque(customAlloc);
  
      CustomQueue&lt;int, CustomAlloc&gt; customQueue(STLAdaptor&lt;int, CustomAlloc&gt;{customAlloc});
  
      return 0;
  }
  </code></pre>
  <p>This works perfectly fine, but it's code-gore to have to pass in the <code>STLAdaptor&lt;int, CustomAlloc&gt;{customAlloc}</code> where all other STL Containers can rely on the converting constructor for the <code>STLAdaptor</code>.</p>
  <p>What I'd like to do is:</p>
  <pre><code>int main()
  {
      CustomAlloc customAlloc(3000000);
  
      CustomDeque&lt;int, CustomAlloc&gt; customDeque(customAlloc);
  
      CustomQueue&lt;int, CustomAlloc&gt; customQueue(customAlloc);
  
      return 0;
  }
  </code></pre>
  <p>Where the <code>customAlloc</code> is somehow passed to the underlying <code>std::deque</code>.</p>