220 36861 <8e456af5-09c3-461d-8562-30df127e93af@isocpp.org> article
Path: news.gmane.org!.POSTED!not-for-mail
From: inkwizytoryankes@gmail.com
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: String interpolation
Date: Sat, 10 Feb 2018 10:39:45 -0800 (PST)
Lines: 410
Approved: news@gmane.org
Message-ID: <8e456af5-09c3-461d-8562-30df127e93af@isocpp.org>
References: <356d5835-f1bf-4699-94f5-0b2d3d0b9c0e@isocpp.org>
 <CAMD6iD9aT26x8GQHnQL+kuj3Rq8fVQSfYYFtvTnFidkf6jU_ag@mail.gmail.com>
 <25CCF885-86AD-4D51-8F5C-C46376D34DE0@gmail.com> <4890431.TR9UepuQra@tjmaciei-mobl1>
 <CALvx3hac77b6Z=EOWzKqynALi1-352OvY0dnnOer8rN6tfa01g@mail.gmail.com> <1cdb6300-7397-46d7-bce9-62e6e8dac40b@isocpp.org>
 <CAC+0CCOSZHaTA=YPSDU8Add7mE_BYcYPRCmGW8TRPtZhdqL8Hw@mail.gmail.com>
 <4bce681e-e729-4124-9322-69291fdb6678@isocpp.org>
 <f5feb9a0-99d3-433a-ae46-af34c8d00a61@isocpp.org>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: blaine.gmane.org
Mime-Version: 1.0
Content-Type: multipart/mixed; 
	boundary="----=_Part_6744_1031796837.1518287985319"
X-Trace: blaine.gmane.org 1518287884 25217 195.159.176.226 (10 Feb 2018 18:38:04 GMT)
X-Complaints-To: usenet@blaine.gmane.org
NNTP-Posting-Date: Sat, 10 Feb 2018 18:38:04 +0000 (UTC)
To: ISO C++ Standard - Future Proposals <std-proposals@isocpp.org>
Original-X-From: std-proposals+bncBDDLTAGNTIBBB4XY7TJQKGQEF4KGISI@isocpp.org Sat Feb 10 19:38:00 2018
Return-path: <std-proposals+bncBDDLTAGNTIBBB4XY7TJQKGQEF4KGISI@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-ua0-f199.google.com ([209.85.217.199])
	by blaine.gmane.org with esmtp (Exim 4.84_2)
	(envelope-from <std-proposals+bncBDDLTAGNTIBBB4XY7TJQKGQEF4KGISI@isocpp.org>)
	id 1eka1u-000575-I5
	for gclcip-std-proposals@m.gmane.org; Sat, 10 Feb 2018 19:37:42 +0100
Original-Received: by mail-ua0-f199.google.com with SMTP id z11sf7257657uaz.0
        for <gclcip-std-proposals@m.gmane.org>; Sat, 10 Feb 2018 10:39:48 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=isocpp-org.20150623.gappssmtp.com; s=20150623;
        h=date:from:to:message-id:in-reply-to:references:subject:mime-version
         :x-original-sender:reply-to:precedence:mailing-list:list-id
         :list-post:list-help:list-archive:list-subscribe:list-unsubscribe;
        bh=5WjwGrjUf5nDAz6FLTxJsjo3SsuCxONvnE7M5xBN4/U=;
        b=GxVZDu0ZuZPtYHgLZxRX5db9g5U3OjUv0X4K8SwKBC7+vkl1h7jeFch3xBtaSkPzZ5
         3BZv8TqPLI6TyrcOgrB6BGFq+RRwCNH+vG7W6FeatKyHKFPSXmcHQBgfYjD5mAXS1Df6
         Xmnh07WrDV0eU4s9QN9zhiMA1s4jytAF+s4b2/dxWlBC2WQMREcMctN1mLyQdS7vmkjS
         44mqHAWZV6cXjo0nh4jCJzN0W7qCYmpGDzNop8sKxmHC/dN9lK8gDtSx+9nXvfVVYQZT
         VGffGzHasNsLRN6F9iBQyQjOKQq7MeMlGpKH8yX1tO6SDo6bkbk+y2YyecXSNL4hZ4mm
         d/ig==
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20161025;
        h=date:from:to:message-id:in-reply-to:references:subject:mime-version
         :x-original-sender:reply-to:precedence:mailing-list:list-id
         :list-post:list-help:list-archive:list-subscribe:list-unsubscribe;
        bh=5WjwGrjUf5nDAz6FLTxJsjo3SsuCxONvnE7M5xBN4/U=;
        b=PG3N8RDDwOSvFeC4mZ8sCGDRkzBhSKNvY3wZULEdfo095iiBZM0CoKKqXNSISi0Fqo
         YGU3Y3wTBuA5yD7eZfCPP/4YxAfL88pEPBf1D8SizeUoolhtJmwYnWmOcwwJHKI4+N/7
         AOSgu0lC9NjSFI75z7bccGZznuOfL2gHzoncFWbCtyWnXr3HiDg6b4DWV2EmNeQ+nz53
         jlE4+OpOdz6twD1VD7JPiqwDY+WBfDf4LiwJzF6Y3u4w2AthLAKlmJ8Cvk311/J/9fi6
         YhGED4XZF7n+13GkkYR3v4zDdkbyiLPhmq94/UGtPuQU7emm7rJF8g6kkJjQ8LmA4XN9
         JWBQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20161025;
        h=x-gm-message-state:date:from:to:message-id:in-reply-to:references
         :subject:mime-version:x-original-sender:reply-to:precedence
         :mailing-list:list-id:x-spam-checked-in-group:list-post:list-help
         :list-archive:list-subscribe:list-unsubscribe;
        bh=5WjwGrjUf5nDAz6FLTxJsjo3SsuCxONvnE7M5xBN4/U=;
        b=KJhbElPR2T/EfgRLg/vFcNBCUOojNrcugT6okhHOYLbzD5syUz28RbGUD79ebdPzu1
         /TJUo8M8EFHiF1+Ow0q6n9LY20oSenmUEsQN+npNn04bQ6oMyIoeZ8/jkNPmG+3Tiiba
         XcgnkwEdPtIOPoUkncfgsTl0LYSWwdkmNVV8Y3wSdb03wE8QwkJfFx+OkKEPU3zPhwxX
         DmUO4BhSyWrRpiTwJ3jtfV2tYv2VhHf5tAIdKnqUiEu9haHYZwgK+GFUpoZnmmQQU9rS
         Zl2HlrYCckSG2nCXGoiWGrNB7AARQQSwlIR8TQlOpYYb+ciKBo9dzFp6BiKPoaA5u0nl
         6URg==
X-Gm-Message-State: APf1xPDCMmUtmdY5ZWpQMEVBLn6g1hfHsx6Rx3jBHpR3yXDwpIe/dItI
	NQGuQW0Yk47tfe48a7q8IoE93g==
X-Google-Smtp-Source: AH8x225vm9/XTymUUl3IVqxqMnRzN/709QRrYLKq77N/lcMEkQn3I05SjmndRKpnLvpQqz7/tTS8Tg==
X-Received: by 10.159.36.17 with SMTP id 17mr3847250uaq.119.1518287987668;
        Sat, 10 Feb 2018 10:39:47 -0800 (PST)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.31.191.147 with SMTP id p141ls5306370vkf.19.gmail; Sat, 10 Feb
 2018 10:39:46 -0800 (PST)
X-Received: by 10.31.136.139 with SMTP id k133mr573291vkd.8.1518287985849;
        Sat, 10 Feb 2018 10:39:45 -0800 (PST)
In-Reply-To: <f5feb9a0-99d3-433a-ae46-af34c8d00a61@isocpp.org>
X-Original-Sender: inkwizytoryankes@gmail.com
Precedence: list
Mailing-list: list std-proposals@isocpp.org; contact std-proposals+owners@isocpp.org
List-ID: <std-proposals.isocpp.org>
X-Spam-Checked-In-Group: std-proposals@isocpp.org
X-Google-Group-Id: 399137483710
List-Post: <https://groups.google.com/a/isocpp.org/group/std-proposals/post>, <mailto:std-proposals@isocpp.org>
List-Help: <https://support.google.com/a/isocpp.org/bin/topic.py?topic=25838>, <mailto:std-proposals+help@isocpp.org>
List-Archive: <https://groups.google.com/a/isocpp.org/group/std-proposals/>
List-Subscribe: <https://groups.google.com/a/isocpp.org/group/std-proposals/subscribe>,
 <mailto:std-proposals+subscribe@isocpp.org>
List-Unsubscribe: <mailto:googlegroups-manage+399137483710+unsubscribe@googlegroups.com>,
 <https://groups.google.com/a/isocpp.org/group/std-proposals/subscribe>
Xref: news.gmane.org gmane.comp.lang.c++.isocpp.proposals:36861
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/36861>

------=_Part_6744_1031796837.1518287985319
Content-Type: multipart/alternative; 
	boundary="----=_Part_6745_2004159494.1518287985320"

------=_Part_6745_2004159494.1518287985320
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable



On Saturday, February 10, 2018 at 6:30:15 AM UTC+1, Nicol Bolas wrote:
>
>
>
> On Friday, February 9, 2018 at 5:12:26 PM UTC-5, Marcin Jaczewski wrote:
>>
>>
>>
>> On Friday, February 9, 2018 at 10:13:10 PM UTC+1, Jake Arkinstall wrote:
>>>
>>>
>>>
>>> On 9 Feb 2018 20:51, <inkwizyt...@gmail.com> wrote:
>>>
>>>
>>> Minimal version than could be added to C++ is new string prefix `F`=20
>>> (because we have `R`, `u`, `u8` and `U` already, and `$` is outside of=
=20
>>> source characters) that enable mixing code with string literals.
>>> As Marcel Kr=C3=BCger wrote, language could transform this string liter=
al to:
>>> F"testA{a}test{{B}}"_x; =3D> operator""_x("testA"_x, a, "test{B}"_x); /=
/using=20
>>> same postfix to parse sub-literals
>>> FR"aa(x{b}y)aa"_x; =3D> operator""_x(R"aa(x)aa"_x, b, R"aa(y)aa"_x); //=
it=20
>>> have precedence over `R` prefix
>>>
>>>
>>>
>>> Rest will be implemented by library, this mean `F"a {5} b"` will not=20
>>> compile because there is no matching operator. stl could add this opera=
tor=20
>>> for `s` postfix, that will use `std::to_string` for conversing all=20
>>> arguments:
>>> template<typename... Parts>
>>> std::string operator""s(Parts&&... p) { return std::to_string(std::
>>> forward<Parts>(p)) + ...; }
>>>
>>> int main()
>>> {
>>>     auto x =3D F"Test {{a}} =3D {10+5}"s; //x =3D=3D "Test {a} =3D 15"s
>>> }
>>> No iosteam, and even more it could if someone relay desire to have=20
>>> localizations:
>>>
>>> F"Test {356*10}"_loc("Prod {0} OK!", "fr") =3D=3D "Prod 3.560,00 OK!";
>>>
>>> Only drawback is some template bloat but this is probably acceptable=20
>>> cost.
>>>
>>>
>>> This is exactly the kind of thing I'm aiming for, although I dont=20
>>> believe string conversion and concatenation to be the final solution -=
=20
>>> unless my recall of benchmarks is out of date, streams are faster than=
=20
>>> string concatenation.
>>>
>>> This being said, similar ideas can be applied to utilise the fmt=20
>>> library, for example.
>>>
>> =20
>> This is irrelevant, how it will be implemented is QoI, It could be done=
=20
>> using `snprintf`, or even not implemented at all, only prefix `F`and its=
=20
>> transformation is important.
>>
>> More I think about this more it look as great addition to language:
>> std::string a;
>> int b =3D 0;
>> int c =3D 42;
>> db.run(F"select name as {a}, age as {b} from table where id =3D {c}"_sql=
);
>>
>>
> If how this is implemented is a mere implementation detail, how would you=
=20
> make it use bound parameters or otherwise sanitize string inputs? Have we=
=20
> learned nothing from Little Bobby Tables <https://xkcd.com/327/>?
>
> Indeed, this seems like a justification to *not* provide this feature.
>
=20

But it can easy check it, `_sql` is not string, if you pass string then it=
=20
will be escaped before it is appended to finals string that is send to=20
database.
And how it will be exactly implemented? Like this:
db.run(operator""_sql("select name as "_sql, a, ", age as "_sql, b, "from=
=20
table where id =3D "_sql, c, ""_sql));

This will call:
sql_command operator""_sql(sql_command, std::string& a, sql_command, int& b=
,=20
sql_command, int& c, sql_command);

We have all needed information how to handle each parameter.
We can take address of `a`, `b`, and `c`. We can merge parts of sql and=20
merge in one querry.
From that we can deduce usage and if type is string we add quotes and=20
escapes value (if we need pass some sql part then we use `" and state =3D 1=
=20
"_sql` that return `sql_command` not `std::string`).
It could too simply forward to some current implementation like:
auto sql =3D sql_command("select name as PARAM_0, age as PARAM_1 from table=
=20
where id =3D $0").bind(0, c).execute(db);
a =3D sql.get<std::string>("PARAM_0");
b =3D sql.get<int>("PARAM_1");

Some of this transformation can be done at compile time (like constexpr=20
regexp).

Because we can take reference to object then we can do two-way=20
communication.



--=20
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp=
..org/d/msgid/std-proposals/8e456af5-09c3-461d-8562-30df127e93af%40isocpp.or=
g.

------=_Part_6745_2004159494.1518287985320
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><br><br>On Saturday, February 10, 2018 at 6:30:15 AM UTC+1=
, Nicol Bolas wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;ma=
rgin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir=
=3D"ltr"><br><br>On Friday, February 9, 2018 at 5:12:26 PM UTC-5, Marcin Ja=
czewski wrote:<blockquote class=3D"gmail_quote" style=3D"margin:0;margin-le=
ft:0.8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir=3D"ltr"><br>=
<br>On Friday, February 9, 2018 at 10:13:10 PM UTC+1, Jake Arkinstall wrote=
:<blockquote class=3D"gmail_quote" style=3D"margin:0;margin-left:0.8ex;bord=
er-left:1px #ccc solid;padding-left:1ex"><div dir=3D"auto"><div><br><div><b=
r><div class=3D"gmail_quote">On 9 Feb 2018 20:51,  &lt;<a rel=3D"nofollow">=
inkwizyt...@gmail.com</a>&gt; wrote:<br type=3D"attribution"><blockquote st=
yle=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div =
dir=3D"ltr"><div><br></div><div>Minimal version than could be added to C++ =
is new string prefix `F` (because we have `R`, `u`, `u8` and `U` already, a=
nd `$` is outside of source characters) that enable mixing code with string=
 literals.<br>As Marcel Kr=C3=BCger wrote, language could transform this st=
ring literal to:<br><div style=3D"background-color:rgb(250,250,250);border-=
color:rgb(187,187,187);border-style:solid;border-width:1px"><code><div><spa=
n style=3D"color:#000">F</span><span style=3D"color:#080">&quot;testA{a}tes=
t{{B}}&quot;</span><span style=3D"color:#000">_x</span><span style=3D"color=
:#660">;</span><span style=3D"color:#000"> </span><span style=3D"color:#660=
">=3D&gt;</span><span style=3D"color:#000"> </span><span style=3D"color:#00=
8">operator</span><span style=3D"color:#080">&quot;&quot;</span><span style=
=3D"color:#000">_x</span><span style=3D"color:#660">(</span><span style=3D"=
color:#080">&quot;testA&quot;</span><span style=3D"color:#000">_x</span><sp=
an style=3D"color:#660">,</span><span style=3D"color:#000"> a</span><span s=
tyle=3D"color:#660">,</span><span style=3D"color:#000"> </span><span style=
=3D"color:#080">&quot;test{B}&quot;</span><span style=3D"color:#000">_x</sp=
an><span style=3D"color:#660">);</span><span style=3D"color:#000"> </span><=
span style=3D"color:#800">//using same postfix to parse sub-literals</span>=
<span style=3D"color:#000"><br>FR</span><span style=3D"color:#080">&quot;aa=
(x{b}y)aa&quot;</span><span style=3D"color:#000">_x</span><span style=3D"co=
lor:#660">;</span><span style=3D"color:#000"> </span><span style=3D"color:#=
660">=3D&gt;</span><span style=3D"color:#000"> </span><span style=3D"color:=
#008">operator</span><span style=3D"color:#080">&quot;&quot;</span><span st=
yle=3D"color:#000">_x</span><span style=3D"color:#660">(</span><span style=
=3D"color:#000">R</span><span style=3D"color:#080">&quot;aa(x)aa&quot;</spa=
n><span style=3D"color:#000">_x</span><span style=3D"color:#660">,</span><s=
pan style=3D"color:#000"> b</span><span style=3D"color:#660">,</span><span =
style=3D"color:#000"> R</span><span style=3D"color:#080">&quot;aa(y)aa&quot=
;</span><span style=3D"color:#000">_x</span><span style=3D"color:#660">);</=
span><span style=3D"color:#000"> </span><span style=3D"color:#800">//it hav=
e precedence over `R` prefix</span></div></code></div><br><br><br>Rest will=
 be implemented by library, this mean `F&quot;a {5} b&quot;` will not compi=
le because there is no matching operator. stl could add this operator for `=
s` postfix, that will use `std::to_string` for conversing all arguments:<br=
><div style=3D"background-color:rgb(250,250,250);border-color:rgb(187,187,1=
87);border-style:solid;border-width:1px"><code><div><span style=3D"color:#0=
08">template</span><span style=3D"color:#660">&lt;</span><span style=3D"col=
or:#008">typename</span><span style=3D"color:#660">...</span><span style=3D=
"color:#000"> </span><span style=3D"color:#606">Parts</span><span style=3D"=
color:#660">&gt;</span><span style=3D"color:#000"><br>std</span><span style=
=3D"color:#660">::</span><span style=3D"color:#008">string</span><span styl=
e=3D"color:#000"> </span><span style=3D"color:#008">operator</span><span st=
yle=3D"color:#080">&quot;&quot;</span><span style=3D"color:#000">s</span><s=
pan style=3D"color:#660">(</span><span style=3D"color:#606">Parts</span><sp=
an style=3D"color:#660">&amp;&amp;...</span><span style=3D"color:#000"> p</=
span><span style=3D"color:#660">)</span><span style=3D"color:#000"> </span>=
<span style=3D"color:#660">{</span><span style=3D"color:#000"> </span><span=
 style=3D"color:#008">return</span><span style=3D"color:#000"> std</span><s=
pan style=3D"color:#660">::</span><span style=3D"color:#000">to_string</spa=
n><span style=3D"color:#660">(</span><span style=3D"color:#000">std</span><=
span style=3D"color:#660">::</span><span style=3D"color:#000">forward</span=
><span style=3D"color:#660">&lt;</span><span style=3D"color:#606">Pa<wbr>rt=
s</span><span style=3D"color:#660">&gt;(</span><span style=3D"color:#000">p=
</span><span style=3D"color:#660">))</span><span style=3D"color:#000"> </sp=
an><span style=3D"color:#660">+</span><span style=3D"color:#000"> </span><s=
pan style=3D"color:#660">...;</span><span style=3D"color:#000"> </span><spa=
n style=3D"color:#660">}</span><span style=3D"color:#000"><br><br></span><s=
pan style=3D"color:#008">int</span><span style=3D"color:#000"> main</span><=
span style=3D"color:#660">()</span><span style=3D"color:#000"><br></span><s=
pan style=3D"color:#660">{</span><span style=3D"color:#000"><br>=C2=A0 =C2=
=A0 </span><span style=3D"color:#008">auto</span><span style=3D"color:#000"=
> x </span><span style=3D"color:#660">=3D</span><span style=3D"color:#000">=
 F</span><span style=3D"color:#080">&quot;Test {{a}} =3D {10+5}&quot;</span=
><span style=3D"color:#000">s</span><span style=3D"color:#660">;</span><spa=
n style=3D"color:#000"> </span><span style=3D"color:#800">//x =3D=3D &quot;=
Test {a} =3D 15&quot;s</span><span style=3D"color:#000"><br></span><span st=
yle=3D"color:#660">}</span><span style=3D"color:#000"><br></span></div></co=
de></div><code>No iosteam, and even more it could if someone relay desire t=
o have localizations:<br><br><div style=3D"background-color:rgb(250,250,250=
);border-color:rgb(187,187,187);border-style:solid;border-width:1px"><code>=
<div><span style=3D"color:#000">F</span><span style=3D"color:#080">&quot;Te=
st {356*10}&quot;</span><span style=3D"color:#000">_loc</span><span style=
=3D"color:#660">(</span><span style=3D"color:#080">&quot;Prod {0} OK!&quot;=
</span><span style=3D"color:#660">,</span><span style=3D"color:#000"> </spa=
n><span style=3D"color:#080">&quot;fr&quot;</span><span style=3D"color:#660=
">)</span><span style=3D"color:#000"> </span><span style=3D"color:#660">=3D=
=3D</span><span style=3D"color:#000"> </span><span style=3D"color:#080">&qu=
ot;Prod 3.560,00 OK!&quot;</span><span style=3D"color:#660">;</span><span s=
tyle=3D"color:#000"><br></span></div></code></div><br>Only drawback is some=
 template bloat but this is probably acceptable cost.</code></div></div></b=
lockquote></div></div></div><div dir=3D"auto"><br></div><div dir=3D"auto">T=
his is exactly the kind of thing I&#39;m aiming for, although I dont believ=
e string conversion and concatenation to be the final solution - unless my =
recall of benchmarks is out of date, streams are faster than string concate=
nation.</div><div dir=3D"auto"><br></div><div dir=3D"auto">This being said,=
 similar ideas can be applied to utilise the fmt library, for example.</div=
></div></blockquote><div>=C2=A0<br>This is irrelevant, how it will be imple=
mented is QoI, It could be done using `snprintf`, or even not implemented a=
t all, only prefix `F`and its transformation is important.<br><br>More I th=
ink about this more it look as great addition to language:<br><div style=3D=
"background-color:rgb(250,250,250);border-color:rgb(187,187,187);border-sty=
le:solid;border-width:1px"><code><div><span style=3D"color:#000">std</span>=
<span style=3D"color:#660">::</span><span style=3D"color:#008">string</span=
><span style=3D"color:#000"> a</span><span style=3D"color:#660">;</span><sp=
an style=3D"color:#000"><br></span><span style=3D"color:#008">int</span><sp=
an style=3D"color:#000"> b </span><span style=3D"color:#660">=3D</span><spa=
n style=3D"color:#000"> </span><span style=3D"color:#066">0</span><span sty=
le=3D"color:#660">;</span><span style=3D"color:#000"><br></span><span style=
=3D"color:#008">int</span><span style=3D"color:#000"> c </span><span style=
=3D"color:#660">=3D</span><span style=3D"color:#000"> </span><span style=3D=
"color:#066">42</span><span style=3D"color:#660">;</span><span style=3D"col=
or:#000"><br>db</span><span style=3D"color:#660">.</span><span style=3D"col=
or:#000">run</span><span style=3D"color:#660">(</span><span style=3D"color:=
#000">F</span><span style=3D"color:#080">&quot;select name as {a}, age as {=
b} from table where id =3D {c}&quot;</span><span style=3D"color:#000">_sql<=
/span><span style=3D"color:#660">);</span><span style=3D"color:#000"><br><b=
r></span></div></code></div></div></div></blockquote><div><br>If how this i=
s implemented is a mere implementation detail, how would you make it use bo=
und parameters or otherwise sanitize string inputs? Have we learned nothing=
 from <a href=3D"https://xkcd.com/327/" target=3D"_blank" rel=3D"nofollow" =
onmousedown=3D"this.href=3D&#39;https://www.google.com/url?q\x3dhttps%3A%2F=
%2Fxkcd.com%2F327%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFtYwt6Qicp6LHU=
xtH-OvBP7DZQjw&#39;;return true;" onclick=3D"this.href=3D&#39;https://www.g=
oogle.com/url?q\x3dhttps%3A%2F%2Fxkcd.com%2F327%2F\x26sa\x3dD\x26sntz\x3d1\=
x26usg\x3dAFQjCNFtYwt6Qicp6LHUxtH-OvBP7DZQjw&#39;;return true;">Little Bobb=
y Tables</a>?<br><br>Indeed, this seems like a justification to <i>not</i> =
provide this feature.<br></div></div></blockquote><div>=C2=A0<br><br>But it=
 can easy check it, `_sql` is not string, if you pass string then it will b=
e escaped before it is appended to finals string that is send to database.<=
br>And how it will be exactly implemented? Like this:<br><div style=3D"back=
ground-color: rgb(250, 250, 250); border-color: rgb(187, 187, 187); border-=
style: solid; border-width: 1px; overflow-wrap: break-word;" class=3D"prett=
yprint"><code class=3D"prettyprint"><div class=3D"subprettyprint"><span sty=
le=3D"color: #000;" class=3D"styled-by-prettify">db</span><span style=3D"co=
lor: #660;" class=3D"styled-by-prettify">.</span><span style=3D"color: #000=
;" class=3D"styled-by-prettify">run</span><span style=3D"color: #660;" clas=
s=3D"styled-by-prettify">(</span><span style=3D"color: #008;" class=3D"styl=
ed-by-prettify">operator</span><span style=3D"color: #080;" class=3D"styled=
-by-prettify">&quot;&quot;</span><span style=3D"color: #000;" class=3D"styl=
ed-by-prettify">_sql</span><span style=3D"color: #660;" class=3D"styled-by-=
prettify">(</span><span style=3D"color: #080;" class=3D"styled-by-prettify"=
>&quot;select name as &quot;</span><span style=3D"color: #000;" class=3D"st=
yled-by-prettify">_sql</span><span style=3D"color: #660;" class=3D"styled-b=
y-prettify">,</span><span style=3D"color: #000;" class=3D"styled-by-prettif=
y"> a</span><span style=3D"color: #660;" class=3D"styled-by-prettify">,</sp=
an><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span =
style=3D"color: #080;" class=3D"styled-by-prettify">&quot;, age as &quot;</=
span><span style=3D"color: #000;" class=3D"styled-by-prettify">_sql</span><=
span style=3D"color: #660;" class=3D"styled-by-prettify">,</span><span styl=
e=3D"color: #000;" class=3D"styled-by-prettify"> b</span><span style=3D"col=
or: #660;" class=3D"styled-by-prettify">,</span><span style=3D"color: #000;=
" class=3D"styled-by-prettify"> </span><span style=3D"color: #080;" class=
=3D"styled-by-prettify">&quot;from table where id =3D &quot;</span><span st=
yle=3D"color: #000;" class=3D"styled-by-prettify">_sql</span><span style=3D=
"color: #660;" class=3D"styled-by-prettify">,</span><span style=3D"color: #=
000;" class=3D"styled-by-prettify"> c</span><span style=3D"color: #660;" cl=
ass=3D"styled-by-prettify">,</span><span style=3D"color: #000;" class=3D"st=
yled-by-prettify"> </span><span style=3D"color: #080;" class=3D"styled-by-p=
rettify">&quot;&quot;</span><span style=3D"color: #000;" class=3D"styled-by=
-prettify">_sql</span><span style=3D"color: #660;" class=3D"styled-by-prett=
ify">));</span></div></code></div><br>This will call:<br><div style=3D"back=
ground-color: rgb(250, 250, 250); border-color: rgb(187, 187, 187); border-=
style: solid; border-width: 1px; overflow-wrap: break-word;" class=3D"prett=
yprint"><code class=3D"prettyprint"><div class=3D"subprettyprint"><span sty=
le=3D"color: #000;" class=3D"styled-by-prettify">sql_command </span><span s=
tyle=3D"color: #008;" class=3D"styled-by-prettify">operator</span><span sty=
le=3D"color: #080;" class=3D"styled-by-prettify">&quot;&quot;</span><span s=
tyle=3D"color: #000;" class=3D"styled-by-prettify">_sql</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">(</span><span style=3D"color=
: #000;" class=3D"styled-by-prettify">sql_command</span><span style=3D"colo=
r: #660;" class=3D"styled-by-prettify">,</span><span style=3D"color: #000;"=
 class=3D"styled-by-prettify"> std</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">::</span><span style=3D"color: #008;" class=3D"styl=
ed-by-prettify">string</span><span style=3D"color: #660;" class=3D"styled-b=
y-prettify">&amp;</span><span style=3D"color: #000;" class=3D"styled-by-pre=
ttify"> a</span><span style=3D"color: #660;" class=3D"styled-by-prettify">,=
</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> sql_comma=
nd</span><span style=3D"color: #660;" class=3D"styled-by-prettify">,</span>=
<span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span sty=
le=3D"color: #008;" class=3D"styled-by-prettify">int</span><span style=3D"c=
olor: #660;" class=3D"styled-by-prettify">&amp;</span><span style=3D"color:=
 #000;" class=3D"styled-by-prettify"> b</span><span style=3D"color: #660;" =
class=3D"styled-by-prettify">,</span><span style=3D"color: #000;" class=3D"=
styled-by-prettify"> sql_command</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">,</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify"> </span><span style=3D"color: #008;" class=3D"styled-by-pret=
tify">int</span><span style=3D"color: #660;" class=3D"styled-by-prettify">&=
amp;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> c</sp=
an><span style=3D"color: #660;" class=3D"styled-by-prettify">,</span><span =
style=3D"color: #000;" class=3D"styled-by-prettify"> sql_command</span><spa=
n style=3D"color: #660;" class=3D"styled-by-prettify">);</span></div></code=
></div><br>We have all needed information how to handle each parameter.<br>=
We can take address of `a`, `b`, and `c`. We can merge parts of sql and mer=
ge in one querry.<br>From that we can deduce usage and if type is string we=
 add quotes and escapes value (if we need pass some sql part then we use `&=
quot; and state =3D 1 &quot;_sql` that return `sql_command` not `std::strin=
g`).<br>It could too simply forward to some current implementation like:<br=
><div style=3D"background-color: rgb(250, 250, 250); border-color: rgb(187,=
 187, 187); border-style: solid; border-width: 1px; overflow-wrap: break-wo=
rd;" class=3D"prettyprint"><code class=3D"prettyprint"><div class=3D"subpre=
ttyprint"><span style=3D"color: #008;" class=3D"styled-by-prettify">auto</s=
pan><span style=3D"color: #000;" class=3D"styled-by-prettify"> sql </span><=
span style=3D"color: #660;" class=3D"styled-by-prettify">=3D</span><span st=
yle=3D"color: #000;" class=3D"styled-by-prettify"> sql_command</span><span =
style=3D"color: #660;" class=3D"styled-by-prettify">(</span><span style=3D"=
color: #080;" class=3D"styled-by-prettify">&quot;select name as PARAM_0, ag=
e as PARAM_1 from table where id =3D $0&quot;</span><span style=3D"color: #=
660;" class=3D"styled-by-prettify">).</span><span style=3D"color: #000;" cl=
ass=3D"styled-by-prettify">bind</span><span style=3D"color: #660;" class=3D=
"styled-by-prettify">(</span><span style=3D"color: #066;" class=3D"styled-b=
y-prettify">0</span><span style=3D"color: #660;" class=3D"styled-by-prettif=
y">,</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> c</sp=
an><span style=3D"color: #660;" class=3D"styled-by-prettify">).</span><span=
 style=3D"color: #000;" class=3D"styled-by-prettify">execute</span><span st=
yle=3D"color: #660;" class=3D"styled-by-prettify">(</span><span style=3D"co=
lor: #000;" class=3D"styled-by-prettify">db</span><span style=3D"color: #66=
0;" class=3D"styled-by-prettify">);</span><span style=3D"color: #000;" clas=
s=3D"styled-by-prettify"><br>a </span><span style=3D"color: #660;" class=3D=
"styled-by-prettify">=3D</span><span style=3D"color: #000;" class=3D"styled=
-by-prettify"> sql</span><span style=3D"color: #660;" class=3D"styled-by-pr=
ettify">.</span><span style=3D"color: #008;" class=3D"styled-by-prettify">g=
et</span><span style=3D"color: #660;" class=3D"styled-by-prettify">&lt;</sp=
an><span style=3D"color: #000;" class=3D"styled-by-prettify">std</span><spa=
n style=3D"color: #660;" class=3D"styled-by-prettify">::</span><span style=
=3D"color: #008;" class=3D"styled-by-prettify">string</span><span style=3D"=
color: #660;" class=3D"styled-by-prettify">&gt;(</span><span style=3D"color=
: #080;" class=3D"styled-by-prettify">&quot;PARAM_0&quot;</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">);</span><span style=3D"colo=
r: #000;" class=3D"styled-by-prettify"><br>b </span><span style=3D"color: #=
660;" class=3D"styled-by-prettify">=3D</span><span style=3D"color: #000;" c=
lass=3D"styled-by-prettify"> sql</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">.</span><span style=3D"color: #008;" class=3D"style=
d-by-prettify">get</span><span style=3D"color: #080;" class=3D"styled-by-pr=
ettify">&lt;int&gt;</span><span style=3D"color: #660;" class=3D"styled-by-p=
rettify">(</span><span style=3D"color: #080;" class=3D"styled-by-prettify">=
&quot;PARAM_1&quot;</span><span style=3D"color: #660;" class=3D"styled-by-p=
rettify">);</span></div></code></div><br>Some of this transformation can be=
 done at compile time (like constexpr regexp).<br><br>Because we can take r=
eference to object then we can do two-way communication.<br><br><br><br></d=
iv></div>

<p></p>

-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/8e456af5-09c3-461d-8562-30df127e93af%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/8e456af5-09c3-461d-8562-30df127e93af=
%40isocpp.org</a>.<br />

------=_Part_6745_2004159494.1518287985320--

------=_Part_6744_1031796837.1518287985319--

.
