c++ - Error C2248: 'std::future<Worldlet>::future': can not access private member declared in class std::future<Worldlet> -


i getting error c2248 when try compile struct:

struct loadingworldlet {     int x, z;     std::future<worldlet> result; }; 

i have tried make result reference, error c2512. when fix error c2582 in xutility. way fix first error without getting second two, or way fix both of second 2 errors?

replace std::future<worldlet> std::shared_future<worldlet> might solve immediate compiling problem.

but root of problem want 1 consumer of std::future. copying struct somewhere, asking 2 futures tied same source promise (or whatever source).

std::future designed deliver data once, 1 consumer. if want move around, have move it, not copy it.

as guess error, compiling in msvc2012. compiler lacks automatic move constructor , assignment constructor creation. try adding explicit move constructor , move-assign method.

struct loadingworldlet {   int x, z;   std::future<worldlet> result;   loadingworldlet(loadingworldlet&& o):x(o.x),y(o.y),result(std::move(o.result)) {}   loadingworldlet& operator=(loadingworldlet&& o) {     x = o.x;     y = o.y;     result = std::move(o.result);     return *this;   } }; 

then, avoid implicitly copying loadingworldlet.


Comments

Popular posts from this blog

assembly - 8086 TASM: Illegal Indexing Mode -

Java, LWJGL, OpenGL 1.1, decoding BufferedImage to Bytebuffer and binding to OpenGL across classes -

javascript - addthis share facebook and google+ url -