Skip to content

Commit

Permalink
Explicitly =delete; Statement::bindNoCopy(..., std::string&&) (#469)
Browse files Browse the repository at this point in the history
Rvalues are inherently unsuitable for no-copy binding, because their
lifetime cannot be guaranteed. Separately declare, and delete, all
overloads of bindNoCopy() that take a std::string rvalue.
  • Loading branch information
SRombauts authored Aug 15, 2024
2 parents 3d1cd5f + 94c74ed commit c6032d8
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions include/SQLiteCpp/Statement.h
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,11 @@ class SQLITECPP_API Statement
* @warning Uses the SQLITE_STATIC flag, avoiding a copy of the data. The string must remains unchanged while executing the statement.
*/
void bindNoCopy(const int aIndex, const void* apValue, const int aSize);
/**
* @brief Deleted, because the value's lifetime could not be guaranteed. Use bind().
*/
void bindNoCopy(const int aIndex, std::string&& aValue) = delete;

/**
* @brief Bind a NULL value to a parameter "?", "?NNN", ":VVV", "@VVV" or "$VVV" in the SQL prepared statement (aIndex >= 1)
*
Expand Down Expand Up @@ -271,6 +276,10 @@ class SQLITECPP_API Statement
{
bindNoCopy(getIndex(apName), apValue, aSize);
}
/**
* @brief Deleted, because the value's lifetime could not be guaranteed. Use bind().
*/
void bindNoCopy(const char* apName, std::string&& aValue) = delete;
/**
* @brief Bind a NULL value to a named parameter "?NNN", ":VVV", "@VVV" or "$VVV" in the SQL prepared statement (aIndex >= 1)
*
Expand Down Expand Up @@ -368,6 +377,10 @@ class SQLITECPP_API Statement
{
bindNoCopy(aName.c_str(), apValue, aSize);
}
/**
* @brief Deleted, because the value's lifetime could not be guaranteed. Use bind().
*/
void bindNoCopy(const std::string& aName, std::string&& aValue) = delete;
/**
* @brief Bind a NULL value to a named parameter "?NNN", ":VVV", "@VVV" or "$VVV" in the SQL prepared statement (aIndex >= 1)
*
Expand Down

0 comments on commit c6032d8

Please sign in to comment.