Is it possible to store/retrieve structs where at least one data member is a smart pointer?
Any example?
Thanks!!
There is an example already located in readme. std::shared_ptr and std::unique_ptr map to a storage as a nullable types by default as is. Also you can bind your custom type as a nullable. For example nullable enum
Ok, but the general case where std::shared_ptr holds a class does not work, right? Need to implement the relationship between entities with foreign keys, correct? That is, the following will not compile ever:
class Category
{
public:
std::string m_name;
bool m_real_expense_or_income;
};
class StatementLine
{
public:
std::shared_ptr<Category> m_category;
}
Thanks!
yes, std::shared_ptr works out of the box only if you use basic types like int, float, std::string and other that can map to a column. The thing you want is the same thing you were asking in https://github.com/fnc12/sqlite_orm/issues/184
I apologize if I repeated the question.. Thanks for answering though.
@juandent was it clear for you or do I need to answer it somehow another way?
I think I get it: basically connect entities with foreign/primary keys.
Thank you so much!