title: C++: avoiding the "use of deleted function" error
body: <p>I have written a small class that implements a special thread safe queue that backups itself into a data base a few seconds after the last write into this queue (so if the queue is read before that the data base would be left alone).</p>
  
  <p>I need several of these queues and at one point I need access to them all, so I had the idea of putting them into a <code>std::map</code> so I can access a single queue by its key and all of them with an iterator.
  Unfortunately I get the "use of deleted function" error when trying to <code>insert()</code> a pair of a key and the according queue object. While looking up the meaning I have realised that the problem is probably my usage of <code>std::mutex</code> to make the queue thread-safe (an absolutely important requirement in my use case) and <code>std::mutex</code> is apparently non-movable and non-copyable.</p>
  
  <p>So my question is: what do I have to do to put several instances of that class into a <code>std::map</code>? I mean, there is no real need to copy anything, I won't resize the map after populating it once at the start, I won't delete any object from it and the map has a life time from start of the application and until the machine reboots. The map itself is declared a static and I won't ever make any copies of this map, I just want to access the queues in a comfortable way and efficiency is a non-issue, only code readability.</p>
  
  <p>Here is what the queue class looks like:</p>
  
  <pre><code>class QueueData
  {
      public:
          QueueData(std::string table);
          long GetLastSync(void);
          void PushRecord(const std::string&amp; msg);
          std::string PopRecord(void);
          void PopulateQueue(void);
          void DumpQueue(void);
          void Clear(void);
          size_t GetSize(void);
      private:
          std::string _table;
          std::deque&lt;std::string&gt; _queue;
          long _lastSync;
          std::mutex _mxqueue;
  };
  </code></pre>