c++ - error C2512 in a struct with no explicit constructor -


i receiving error c2512: 'loadingworldlet' : no appropriate default constructor available, when try compile file. there no explicit constructor, can not think of reason me recieving error.

struct worldlet {     int x, z;     glm::mat4 worldletmatrix;     std::vector<voxel> blocks; };  struct loadingworldlet {     int x, z;     std::future<worldlet> &result; };  class world { public:     world();     ~world();      void init();     void initrenderable();     void updateworldletlist(int x, int z);      void render(shader* worldshader, camera *mainpov);      static worldlet loadworldlet(int x, int z, std::ifstream &file); private:     std::vector<worldlet> worldlets;     std::vector<loadingworldlet> loadingworldlets;     std::vector<std::string> loadingtitles;     std::vector<int> toremove;      renderable cube;      std::string worldname, prefix;      static const float cube_size;     static const int loadlimit = 1;      int getloadradius(int r = 0) {         static int = r;         return i;     } }; 

this function in loadingworldlet used:

void world::updateworldletlist(int x, int z) {     static int previousx, previousz;      for(int index: toremove) {         worldlets.erase(worldlets.begin() + index);     }     toremove.clear();      int loaded = 0;      std::vector<int> clearlist;     for(auto &loading: loadingworldlets) {         if(loaded >= loadlimit) break;          worldlets.push_back(loading.result.get());         clearlist.push_back(loaded);         loaded++;     }     for(int i: clearlist)         loadingworldlets.erase(loadingworldlets.begin()+i);      if(previousx != x && previousz != z) {         int = 0;         for(auto worldlet: worldlets) {             if(pow(worldlet.x - x, 2) + pow(worldlet.z - z, 2) > getloadradius()) {                 toremove.push_back(i);             }             i++;         }         for(int recx = -getloadradius(); recx < getloadradius(); recx++) {             for(int recz = -getloadradius(); recz < getloadradius(); recz++) {                 bool cont = false;                 for(auto worldlet: worldlets) {                     if (worldlet.x == recx && worldlet.z == recz) {                         cont = true;                         break;                     }                 }                 for(auto loading: loadingworldlets) {                     if (loading.x == recx && loading.z == recz) {                         cont = true;                         break;                     }                 }                 if(cont || pow(recx - x, 2) + pow(recz - z, 2) > getloadradius())                     continue;                  std::ifstream file("./worlds/" + worldname + "/" + prefix + std::to_string(recx) + "x" + std::to_string(recz) + "z.json");                 if (!file)                     continue;                  loadingworldlet loading;                 loading.x = recx;                 loading.z = recz;                 loading.result = std::async(loadworldlet, recx, recz, file);                 loadingworldlets.push_back(loading);             }         }     } } 

i have tried adding default constructor, receive error missing = operator. doesn't compiler automatically add in these things? how can fix error? if important, using visual studio 2013 preview.

looking on code, you'll need way instantiate reference std::future<worldlet> &result;

typically, done through constructor.

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

otherwise, not make data member reference ( assumes other data members don't have mandatory constructors):

std::future<worldlet> result;


Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -