title: How to pass value with std::move in lambda function
body: <p>First of all I apologize if it gets too long, as the problem can be detailed quickly, however, I describe a good part of the environment to perhaps come and help.</p>
  <p>I'm developing a tool in C++ that analyzes genomic data (FASTQ data specifically). In case you don't know, a FASTQ file contains raw reads of genetic sequence, where each set of 4 lines of this file represents a read of the genome.
  Well, as the processing of a read does not depend on other reads (in my case), I intend to parallelize the work with threads to save processing time.</p>
  <p>When searching, I found some libraries ready and I'm trying to adapt. Right now I'm trying to use Thread Pool (specifically this lib -&gt; <a href="https://github.com/log4cplus/ThreadPool/" rel="nofollow noreferrer">https://github.com/log4cplus/ThreadPool/</a>) but I'm having some problems with the integration.</p>
  <p>I will detail the general algorithm a little.
  Each iteration in the FASTQ file takes a set of 4 lines from the file and stores it in this struct.</p>
  <pre><code>struct READ  {
              std::string name; // Small size
              std::string comment; // Small size
              std::string seq; // String ranging between 0 and 1000 characters
              std::string which; // The same amount of 'seq' characters  
  };
  </code></pre>
  <p>That is immediately passed as a value to the foreign function to perform the (non-trivial) task managed by the Thread Pool.</p>
  <pre><code>ThreadPool pool (4); // Creating thread pool with 4 threads
  
  while (exist_read) // as long as there are reads to be processed -&gt; read set of 4 lines
  {
    Read read;
    read = next_read (); // read will contain 4 lines of the file read in the iteration
    pool.enqueue ([read] {
      Search (read); // search function performs non-trivial search work
    });
  }
  </code></pre>
  <p>As can be seen, I passed the values ​​in the lambda function and tested it with several threads, but I ended up having inferior performance when using single-thread.
  So I was suggested to use a movable object. And with great help, I got this struct.</p>
  <pre><code>struct READ
  {
      READ () = default;
      READ (READ &amp;&amp;) = default;
      READ &amp; operator = (READ &amp;&amp;) = default;
      std::string name;
      std::string comment;
      std::string seq;
      std::string which;
  };
  </code></pre>
  <p>And the lambda function has changed to:</p>
  <pre><code>pool.enqueue ([r {std::move(read)}] {
     Search (std::move(r));
  });
  </code></pre>
  <p>In addition, did update the reading of the FASTQ file of:</p>
  <pre><code>[...]
  Read read;
  read.name = lines[0];
  read.seq = lines[1];
  read.comment = lines[2];
  read.qual = lines[3];
  [...]
  </code></pre>
  <p>To:</p>
  <pre><code>[...]
  Read read;
  read.name = std::move(lines [0]);
  read.seq = std::move(lines [1]);
  read.comment = std::move(lines [2]);
  read.qual = std::move(lines [3]);
  [...]
  </code></pre>
  <p>However, I still haven't been able to test the performance, because I'm having the following <a href="https://i.stack.imgur.com/4rn0N.png" rel="nofollow noreferrer">print_error</a></p>
  <blockquote>
  <p>error: function &quot;READ::READ (const READ &amp;)&quot; (declared implicitly)
  cannot be referenced - it is a deleted function C / C ++ (1776)</p>
  </blockquote>
  <p>I searched other forums but I couldn't find an answer that would suit my problem.
  If anyone can help me with this problem I will be very grateful. I hope I have been clear.
  In addition, I also accept suggestions for other alternatives.</p>
  <p>Thanks.</p>