Is it possible to pass a single object to a method that accepts a container of objects?
E.g.:
I have a custom class Entry
bound to a table from a database:
class Entry
{
public:
Entry(int64_t iId, const std::string &sName);
int64_t id();
std::string name();
private:
int64_t iId_;
std::string sName_;
}
void insert(const std::vector<Entry> &entries)
{
// For the sake of example
session.start();
session << "INSERT INTO MyTable (ID, Name) VALUES " << bind(entries);
session.stop();
}
void function()
{
Entry entry(1, "RandomName");
insert( ? entry ? ); // What should I do here?
}
Is this possible without instantiating a new container for only one object or without overriding the insert
method for receiving a simple object?
Aucun commentaire:
Enregistrer un commentaire