lifetime issue: Bug or not?
Walter Bright
newshound2 at digitalmars.com
Sat Nov 23 04:26:43 UTC 2019
On 11/22/2019 10:54 AM, Steven Schveighoffer wrote:
> I have code in my proprietary project that looks like this:
>
> struct X
> {
> ...
> SQLStatement foo()
> {
> auto stmt = SQLStatement("`foo`"); // table
> return stmt.where("`id` = ?", id);
> }
> }
>
> where is a function that adds a where clause with a given value to the SQL
> statement. It takes an SQLStatement by ref, and returns that statement by ref.
>
> Signature looks like this:
>
> ref SQLStatement where(T)(return ref SQLStatement stmt, string clause, T val)
^^^ ^^^^^^^^^^
> Error: returning where(stmt, "`id` = ?", id) escapes a reference to local
> variable stmt
>
> But... it's not returning a ref.
Yes it is. See the ^^^^
More information about the Digitalmars-d
mailing list