Skip to content

Parent class gets deleted upon initialization of sqlitelib's class #6

@bastien8060

Description

@bastien8060

Hello! I really like this project, however, I have come to an error, which I couldn't fix. It seems that when you initialize a database with sqlitelib in a class, then the =delete operator gets called on the parent class. Eg:

Here I have a class: PokeDex. The classes initializes itself with a database. (I also tried to move the definition to the constructor). It seems my PokeDex object gets deleted.

class PokeDex {       // Sample class
  public:
    Pokemon GetPokemon(string name) const;
    PokeDex();
    sqlitelib::Sqlite db = sqlitelib::Sqlite("./test.db");
};
includes/sqlitelib/sqlitelib.h:279:3: note:   candidate expects 1 argument, 0 provided
dexserver.cpp: In function ‘int main()’:
dexserver.cpp:13:42: error: use of deleted function ‘PokeDex::PokeDex(const PokeDex&)’
   13 |     CROW_ROUTE(dex, "/pokemon/<string>")([pokedex](std::string name){
      |                                          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
   14 |         Pokemon result = pokedex.GetPokemon(name);
      |         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   15 |         std::string body = result.description;
      |         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   16 |         return body;
      |         ~~~~~~~~~~~~
   17 |     });

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions