I'm currently trying to call the sqlite3 library function, and it expects me to pass sqlite3** .
Here is my current code. I have one working part and one part that gives me an error:
sqlite3 *sqlite = m_db.get(); if (sqlite3_open(std::string(m_dbName.begin(), m_dbName.end()).c_str(), &sqlite)) { } if (sqlite3_open(std::string(m_dbName.begin(), m_dbName.end()).c_str(), &(m_db.get()) )) { }
The My m_db field is as follows:
std::unique_ptr<sqlite3> m_db = nullptr;
Of the two examples I cited, the first works fine. However, the second gives me this error. Note that this comes from the &(m_db.get()) :
"Address expression must be an lvalue or a function designator"
I read a little about lvalues and rvalues, but I cannot understand why this syntax is not possible. As far as I understand so far, the problem is that the return value of the .get () operation is just the result of a temporary expression and therefore does not have an identifiable place in memory where I could get the address from.
There must be a way to achieve this in one statement, I think.
Can someone explain to me why this is not working and how can I fix it?
source share