lundi 14 juin 2021

Instance Variable Vector's size is 0 (not initializing) after reinterpret_cast

Hi I am trying to have vectors with predefined sizes in my instance variables. I initialize them like this:

  /// The keys.
  std::vector<KeyT> keys = std::vector<KeyT>(kCapacity);
  /// page ids
  std::vector<uint64_t> children = std::vector<uint64_t>(kCapacity);

I reinterpret_cast some data to the class that contains these variables (LeafNode) but the vector sizes are 0 therefore the following operations crash the program. How can I fix this and make sure size is not 0?

         auto node = reinterpret_cast<LeafNode*>(page.get_data());

Edit: Added whole code to gist: https://gist.github.com/yigiterinc/24adf85e8ae42b7d91454e2c531fbb53

Aucun commentaire:

Enregistrer un commentaire