220 15132 <5c8a1dd2-4664-40ac-90fa-65011612d69b@isocpp.org> article
Path: news.gmane.org!not-for-mail
From: Douglas Boffey <douglas.boffey@gmail.com>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: Inline variables - superior of templates and constexpr.
Date: Wed, 17 Dec 2014 06:25:23 -0800 (PST)
Lines: 796
Approved: news@gmane.org
Message-ID: <5c8a1dd2-4664-40ac-90fa-65011612d69b@isocpp.org>
References: <84da1bdc-3356-4c40-a29a-bdd4c0b058b4@isocpp.org>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: plane.gmane.org
Mime-Version: 1.0
Content-Type: multipart/mixed; 
	boundary="----=_Part_416_1204189752.1418826323071"
X-Trace: ger.gmane.org 1418826331 14519 80.91.229.3 (17 Dec 2014 14:25:31 GMT)
X-Complaints-To: usenet@ger.gmane.org
NNTP-Posting-Date: Wed, 17 Dec 2014 14:25:31 +0000 (UTC)
To: std-proposals@isocpp.org
Original-X-From: std-proposals+bncBDSIZVXVVUFBBU5EY2SAKGQEJVGTNPY@isocpp.org Wed Dec 17 15:25:26 2014
Return-path: <std-proposals+bncBDSIZVXVVUFBBU5EY2SAKGQEJVGTNPY@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-oi0-f71.google.com ([209.85.218.71])
	by plane.gmane.org with esmtp (Exim 4.69)
	(envelope-from <std-proposals+bncBDSIZVXVVUFBBU5EY2SAKGQEJVGTNPY@isocpp.org>)
	id 1Y1FXZ-0004AD-9J
	for gclcip-std-proposals@m.gmane.org; Wed, 17 Dec 2014 15:25:25 +0100
Original-Received: by mail-oi0-f71.google.com with SMTP id u20sf67059474oif.2
        for <gclcip-std-proposals@m.gmane.org>; Wed, 17 Dec 2014 06:25:24 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20120113;
        h=date:from:to:message-id:in-reply-to:references:subject:mime-version
         :content-type:x-original-sender:reply-to:precedence:mailing-list
         :list-id:list-post:list-help:list-archive:list-subscribe
         :list-unsubscribe;
        bh=De0DZqeKI+Ey3uAKvQu9XRWMq9psrcgKV7NupJwYLiI=;
        b=KcN5TxK0pafz0d0tA5KNrBXl/DFUwIMfiTPwGzurAwL04w399d+IRSl3+Cc61/nljF
         zjlXMGmAjo3mp3mZUy1ajcpv95UBl13gPHU891wTdUpj4OzeZyr+4QABeQOCRcdfeqch
         uBx+uUs1j3UIBvkump9H6RazEtdEpVdo6wLbPnQcMJg0MjKYJ1Yj3y+On8hpS2b2nJi0
         6/sp0JoLD3ZfPM0RrVWi8TcQEncYXVxkfIxCclCNdyFN78b79Sa/UkPmyF5KccBcMdkv
         IEOj87k4TUtrhdvAPJ2hsHFkiWzkgc8xUBJcukC5bbALKm77XApztwk+Znfa78Rf3QgW
         sqZg==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20130820;
        h=x-gm-message-state:date:from:to:message-id:in-reply-to:references
         :subject:mime-version:content-type:x-original-sender:reply-to
         :precedence:mailing-list:list-id:list-post:list-help:list-archive
         :list-subscribe:list-unsubscribe;
        bh=De0DZqeKI+Ey3uAKvQu9XRWMq9psrcgKV7NupJwYLiI=;
        b=R86Oy6ZLvr9zsv/rYsJN4U+AYIEJvGd2w8yeQtpGF3u/st7/8anqyeN0XTz7TUESmK
         JQF7oZAbXzhlVNLILIzR7nA6kgkulOZhE1ydYo6zLLC6KQZ+lMfp6IzlqLGFV3mTBJQ8
         306X2o8RcN/QDvfPJIEJ30bImAECM7a73psCwJR6xcjEw8UNcDVE4UvyWNg77EWV/yaf
         N836H8IWhD2DOQmVZi28JOxjFzt/AokQTtLiah2l9vZCdDvBwfDQ+aYvvFVNoxbhE/pS
         2J/LMr3mg9R2EurUm820rLaG7i0UyeyNZet7zRmy0c+pT2la/GR5GQt0DdGetLWSjD8k
         MFOQ==
X-Gm-Message-State: ALoCoQkazmLGNrcOITdgKputMVglA2BNjKdXnG1E53/HLwVAkKpNRc5GHLbyhx65Ael4KeUZFVal
X-Received: by 10.42.22.75 with SMTP id n11mr41007673icb.22.1418826324217;
        Wed, 17 Dec 2014 06:25:24 -0800 (PST)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.140.96.112 with SMTP id j103ls3620447qge.83.gmail; Wed, 17 Dec
 2014 06:25:23 -0800 (PST)
X-Received: by 10.140.27.197 with SMTP id 63mr391881qgx.6.1418826323424;
        Wed, 17 Dec 2014 06:25:23 -0800 (PST)
In-Reply-To: <84da1bdc-3356-4c40-a29a-bdd4c0b058b4@isocpp.org>
X-Original-Sender: Douglas.Boffey@gmail.com
Precedence: list
Mailing-list: list std-proposals@isocpp.org; contact std-proposals+owners@isocpp.org
List-ID: <std-proposals.isocpp.org>
X-Google-Group-Id: 399137483710
List-Post: <http://groups.google.com/a/isocpp.org/group/std-proposals/post>, <mailto:std-proposals@isocpp.org>
List-Help: <http://support.google.com/a/isocpp.org/bin/topic.py?topic=25838>, <mailto:std-proposals+help@isocpp.org>
List-Archive: <http://groups.google.com/a/isocpp.org/group/std-proposals/>
List-Subscribe: <http://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>,
 <http://groups.google.com/a/isocpp.org/group/std-proposals/subscribe>
Xref: news.gmane.org gmane.comp.lang.c++.isocpp.proposals:15132
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/15132>

------=_Part_416_1204189752.1418826323071
Content-Type: multipart/alternative; 
	boundary="----=_Part_417_931272536.1418826323071"

------=_Part_417_931272536.1418826323071
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable


On Tuesday, 16 December 2014 18:50:46 UTC, sasho648 wrote:
>
> As the title says - I'm purposing the introduction of a new variables=20
> specifier - 'inline', which will indicate that their value is known at=20
> compile-time. [Literals aren't itself 'inline' variables, so an reference=
=20
> to 'inline' variable can't bound to literal.] The motivation of introduci=
ng=20
> it is enabling static checks at functions, native 'read-only public' clas=
s=20
> member specifiers and creating more optimized code.
>
> Example of the first one can be given by using 'std::array' if we access=
=20
> an object of the type using the 'operator[]' and 'constexpr' with invalid=
=20
> index no compiler warning or even an error will be introduced:
>
>    =20
> array<int, 5> arr;
>    =20
> cout << arr[98] << endl; //compiles just fine
>
> Life example <http://melpon.org/wandbox/permlink/6AUCctBG2H1gYwXq>.
>
> You'll say - this is too obvious - no one will do such thing but let's=20
> imagine that we are going to access the array element, instead of a=20
> literal, by some constexpr function.
>
> constexpr int EvaluateSpecialArrayIndex(int a)
> { return a * sizeof(int); }
>
> cout << arr[EvaluateSpecialArrayIndex(4)] << endl;
>
> Now things get complex, huh? In order to check if the array index is vali=
d=20
> we should first multiply by hand 4 * sizeof(int) and compare it with the=
=20
> array size. You think now - hey but why don't you add a static_assert in=
=20
> the 'EvaluateSpecialArrayIndex' and check 'a' with the array size. But th=
e=20
> truth is - that you can't do that as the parameter 'a' isn't required to =
be=20
> 'constexpr', neither the return value of the function. Example on valid=
=20
> 'constexpr' call with 'lvalue':
>
>
> int a =3D rand() % 4; //lvalue
>
> cout << arr[EvaluateSpecialArrayIndex(a)] << endl; // also valid
>
> Life example <http://melpon.org/wandbox/permlink/DLuQZd1ECewZkpxQ>.
>
> So this piece of code is invalid:
>
> constexpr int EvaluateSpecialArrayIndex(int a)
> { static_assert( a < 5, "invalid a" ); return a * sizeof(int); }
>
>
> Life example <http://melpon.org/wandbox/permlink/z9uxsbpr9irk2LBR>.
>
> Here is where 'inline' variables came in use. They can be initialized onl=
y=20
> once with another 'inline' variable or with literal but aren't 'const' an=
d=20
> non-'inline' variables can't be casted to 'inline'. However the opposite =
is=20
> possible (casting from 'inline' to any other type). Functions declared wi=
th=20
> 'inline' parameters or return-value will be implicit 'inline' themselves.=
=20
> Instance to a function with argument literal will first search for one wi=
th=20
> parameter of type 'inline <type-of-literal>'. So now we could overload th=
e=20
> 'std::array::operator[]' in order to do static checks on 'inline' variabl=
es=20
> like this (supposing that 'templates' are still used):
>
> template<typename T, size_t sz>
> T & std::array::operator[]( size_type pos )
>
> {
>     static_assert( pos < sz, "invalid array index" );
>
>     return this->operator[]((int)pos); //instance default 'non-inline'=20
> (run-time) operator[] with 'a' casted (from 'inline int') to 'int'
> }
>
>
> By using the above function this invalid code:
>
> array<int, 5> arr;
>    =20
> cout << arr[98] << endl;
>
> Will report compiler error, instead of producing undefined behavior.
>
> The other usage of the specifier, optimizing code, can be demonstrated by=
=20
> creating one general function - for both 'inline' and 'non-inline'=20
> parameters, of certain algorithm and other 2 for 'inline' and 'non-inline=
'=20
> which will specialize it, so when you call it with for example literal - =
it=20
> will be evaluated at compile-time and when you do with some variable it=
=20
> will create code for run-time execution. Example:
>
> auto SomeAlgo(inline bool bIsInline, typename( bIsInline ? inline int :=
=20
> int ) n) -> decltype(n)
> {
>     //Do something with 'n' and return 'int' (or 'inline int')
> }
> =20
>
inline int SomeAlgo(inline int a) { static_assert( a < 0, "invalid a" );=20
> return SomeAlgo(true, a); }
>
> int SomeAlgo(int a) { return SomeAlgo(false, a); }
>
> *Note that the first function is declared as returning an 'inline int', i=
f=20
> it was the function itself to be 'inline', it should be 'int inline=20
> SomeAlgo', which is an inline function returning 'int'.*
>
> And some example instances of 'SomeAlgo':
>
> SomeAlgo(rand()); //it will invoke code creation as 'rand()' doesn't=20
> return 'inline' value
>
> SomeAlgo(9); //Will evaluate at compile-time as literal '9' can be used=
=20
> to initialize 'inline' variables
>
> Another useful feature will be the use of 'inline references' which are=
=20
> such that will point at some compiler-known location (nothing special),=
=20
> they'll be useful when you want to create a public const reference to som=
e=20
> private member in order to allow public read-only access to it. For now w=
e=20
> could only write this:
>
> class A
> {
>     int _a;
>
> public:
>
>     const int &a =3D _a;
> } ;
>
> Life example <http://melpon.org/wandbox/permlink/2Ffi7NKWf86cmcQ6>.
>
> But in the case memory for 'a' will be allocated for each 'A' instance,=
=20
> which is not a deal. We couldn't write this with 'constexpr' for some=20
> strange reason:
>
> class A
> {
>     int _a;
>
> public:
>
>     constexpr int &a =3D _a; // the same as 'const int & constexpr a' -=
=20
> still produces error
> } ;
>
> Life example <http://melpon.org/wandbox/permlink/fGWsVP2bcqhG3zBa>.
>
> By using our new construct this could write this:
>
> class A
> {
>     int _a;
>
> public:
>
>     const int & inline a =3D _a; // inline reference to '_a'
> } ;
>
> Which basically means that each reference to 'a', will be evaluated like =
-=20
> '(const int)_a', so no additional memory will be created now.
>
> Function specialization will be done to functions with 'inline'=20
> parameters, which when receive argument values will search for a function=
=20
> which have specialized them. The parameter specialization will be done vi=
a=20
> the '=3D=3D' operator (one specialization can be for multiples values). E=
xamples
>
> auto FuncAdd(inline typename T, T a, T b) -> T //general function
> {
>     return a + b;
> }
>
> auto FuncAdd(inline typename T =3D=3D int, T a, T b) -> T //specialized=
=20
> function about the 'T' parameter, as no inline params, no implicit 'inlin=
e'=20
> conversion
> {
>     cout << "I can deal with int" << endl;
>
>     return a + b;
> }
>
> Am I to understand the =E2=80=9Cinline typename T=E2=80=9D as an alternat=
ive method of=20
expressing templates or one function that will work for any type?
=20
Firstly, whether or not you want this as a template replacement, I object=
=20
to having to specify the type when the compiler can deduce that from the=20
variables.
=20
If it is meant as a replacement for a template, having the type as a=20
parameter is confusing=E2=80=A6 I would expect one function, and only one f=
unction,=20
to be substantiated when a function is not explicitly templated.
=20
If it is not, I am at a loss as to how a compiler is meant to implement it=
=20
efficiently (or at all, if it is defined in a separate TU).
=20
Regarding the second (overloaded) function, is that supposed to overload on=
=20
type int?  If so, =E2=80=9Cauto FuncAdd(int, =E2=80=A6=E2=80=9D would be mo=
re in line with current=20
practice.  This will not create an ambiguity, as the parameter is already=
=20
defined as a typename.
=20

> And some 'FuncAdd' instances:
>
> FuncAdd(int, 9, 5); // 'FuncAdd' int specialization called (of type -=20
> 'auto (inline typename T =3D=3D int, T a, T b) -> T')
>
> FuncAdd(double, 3.14f, 1); // 'FuncAdd' general called (of type - 'auto=
=20
> (inline typename T, T a, T b) -> T')
>
>
> Some additional 'inline' specifier rules connected to specialization and=
=20
> classes. A class can have special methods for 'inline' instances of it,=
=20
> which are defined by specifiying 'inline' after it's declaration (in such=
=20
> methods 'this' will be inline pointer and will point to an sequenced=20
> 'inline'  array holding it's inline member objects). Inline instances of=
=20
> class will instance only it's special 'inline-this' methods and won't=20
> create any memory for it's non-inline members. Classes can't be specializ=
ed=20
> but you can create a derived class which specialize their methods. But th=
is=20
> could cha
> ...

--=20

---=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.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposa=
ls/.

------=_Part_417_931272536.1418826323071
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><br>On Tuesday, 16 December 2014 18:50:46 UTC, sasho648  w=
rote:<blockquote style=3D"margin: 0px 0px 0px 0.8ex; padding-left: 1ex; bor=
der-left-color: rgb(204, 204, 204); border-left-width: 1px; border-left-sty=
le: solid;" class=3D"gmail_quote"><div dir=3D"ltr">As the title says - I'm =
purposing the introduction of a new variables specifier - 'inline', which w=
ill indicate that their value is known at compile-time. [Literals aren't it=
self 'inline' variables, so an reference to 'inline' variable can't bound t=
o literal.] The motivation of introducing it is enabling static checks at f=
unctions, native 'read-only public' class member specifiers and creating mo=
re optimized code.<br><br>Example of the first one can be given by using 's=
td::array' if we access an object of the type using the 'operator[]' and 'c=
onstexpr' with invalid index no compiler warning or even an error will be i=
ntroduced:<br><br><div>&nbsp; &nbsp;&nbsp;</div><div style=3D"border: 1px s=
olid rgb(187, 187, 187); word-wrap: break-word; background-color: rgb(250, =
250, 250);"><code><div><span style=3D"color: rgb(0, 0, 0);">array</span><sp=
an style=3D"color: rgb(102, 102, 0);">&lt;</span><span style=3D"color: rgb(=
0, 0, 136);">int</span><span style=3D"color: rgb(102, 102, 0);">,</span><sp=
an style=3D"color: rgb(0, 0, 0);"> </span><span style=3D"color: rgb(0, 102,=
 102);">5</span><span style=3D"color: rgb(102, 102, 0);">&gt;</span><span s=
tyle=3D"color: rgb(0, 0, 0);"> arr</span><span style=3D"color: rgb(102, 102=
, 0);">;</span><span style=3D"color: rgb(0, 0, 0);"><br>&nbsp; &nbsp; <br>c=
out </span><span style=3D"color: rgb(102, 102, 0);">&lt;&lt;</span><span st=
yle=3D"color: rgb(0, 0, 0);"> arr</span><span style=3D"color: rgb(102, 102,=
 0);">[</span><span style=3D"color: rgb(0, 102, 102);">98</span><span style=
=3D"color: rgb(102, 102, 0);">]</span><span style=3D"color: rgb(0, 0, 0);">=
 </span><span style=3D"color: rgb(102, 102, 0);">&lt;&lt;</span><span style=
=3D"color: rgb(0, 0, 0);"> endl</span><span style=3D"color: rgb(102, 102, 0=
);">;</span><span style=3D"color: rgb(0, 0, 0);"> </span><span style=3D"col=
or: rgb(136, 0, 0);">//compiles just fine</span></div></code></div><div><br=
></div><div>Life <a onmousedown=3D"this.href=3D'http://www.google.com/url?q=
\75http%3A%2F%2Fmelpon.org%2Fwandbox%2Fpermlink%2F6AUCctBG2H1gYwXq\46sa\75D=
\46sntz\0751\46usg\75AFQjCNEHGAWmo00ulsU7ElO2plX9RLoM8w';return true;" oncl=
ick=3D"this.href=3D'http://www.google.com/url?q\75http%3A%2F%2Fmelpon.org%2=
Fwandbox%2Fpermlink%2F6AUCctBG2H1gYwXq\46sa\75D\46sntz\0751\46usg\75AFQjCNE=
HGAWmo00ulsU7ElO2plX9RLoM8w';return true;" href=3D"http://melpon.org/wandbo=
x/permlink/6AUCctBG2H1gYwXq" target=3D"_blank">example</a>.</div><div><br><=
/div><div>You'll say - this is too obvious - no one will do such thing but =
let's imagine that we are going to access the array element, instead of a l=
iteral, by some constexpr function.<br><br><div></div></div><div style=3D"b=
order: 1px solid rgb(187, 187, 187); word-wrap: break-word; background-colo=
r: rgb(250, 250, 250);"><code><div><span style=3D"color: rgb(0, 0, 136);">c=
onstexpr</span><span style=3D"color: rgb(0, 0, 0);"> </span><span style=3D"=
color: rgb(0, 0, 136);">int</span><span style=3D"color: rgb(0, 0, 0);"> </s=
pan><span style=3D"color: rgb(102, 0, 102);">EvaluateSpecialArrayIndex</spa=
n><span style=3D"color: rgb(102, 102, 0);">(</span><span style=3D"color: rg=
b(0, 0, 136);">int</span><span style=3D"color: rgb(0, 0, 0);"> a</span><spa=
n style=3D"color: rgb(102, 102, 0);">)</span><span style=3D"color: rgb(0, 0=
, 0);"><br></span><span style=3D"color: rgb(102, 102, 0);">{</span><span st=
yle=3D"color: rgb(0, 0, 0);"> </span><span style=3D"color: rgb(0, 0, 136);"=
>return</span><span style=3D"color: rgb(0, 0, 0);"> a </span><span style=3D=
"color: rgb(102, 102, 0);">*</span><span style=3D"color: rgb(0, 0, 0);"> </=
span><span style=3D"color: rgb(0, 0, 136);">sizeof</span><span style=3D"col=
or: rgb(102, 102, 0);">(</span><span style=3D"color: rgb(0, 0, 136);">int</=
span><span style=3D"color: rgb(102, 102, 0);">);</span><span style=3D"color=
: rgb(0, 0, 0);"> </span><span style=3D"color: rgb(102, 102, 0);">}</span><=
span style=3D"color: rgb(0, 0, 0);"><br><br>cout </span><span style=3D"colo=
r: rgb(102, 102, 0);">&lt;&lt;</span><span style=3D"color: rgb(0, 0, 0);"> =
arr</span><span style=3D"color: rgb(102, 102, 0);">[</span><span style=3D"c=
olor: rgb(102, 0, 102);">EvaluateSpecialArrayIndex</span><span style=3D"col=
or: rgb(102, 102, 0);">(</span><span style=3D"color: rgb(0, 102, 102);"><wb=
r>4</span><span style=3D"color: rgb(102, 102, 0);">)]</span><span style=3D"=
color: rgb(0, 0, 0);"> </span><span style=3D"color: rgb(102, 102, 0);">&lt;=
&lt;</span><span style=3D"color: rgb(0, 0, 0);"> endl</span><span style=3D"=
color: rgb(102, 102, 0);">;</span></div></code></div><div><br>Now things ge=
t complex, huh? In order to check if the array index is valid we should fir=
st multiply by hand 4 * sizeof(int) and compare it with the array size. You=
 think now - hey but why don't you add a static_assert in the 'EvaluateSpec=
ialArrayIndex' and check 'a' with the array size. But the truth is - that y=
ou can't do that as the parameter 'a' isn't required to be 'constexpr', nei=
ther the return value of the function. Example on valid 'constexpr' call wi=
th 'lvalue':<br></div><div><br></div><div><br></div><div><div style=3D"bord=
er: 1px solid rgb(187, 187, 187); word-wrap: break-word; background-color: =
rgb(250, 250, 250);"><code><div><span style=3D"color: rgb(0, 0, 136);">int<=
/span><span style=3D"color: rgb(0, 0, 0);"> a </span><span style=3D"color: =
rgb(102, 102, 0);">=3D</span><span style=3D"color: rgb(0, 0, 0);"> rand</sp=
an><span style=3D"color: rgb(102, 102, 0);">()</span><span style=3D"color: =
rgb(0, 0, 0);"> </span><span style=3D"color: rgb(102, 102, 0);">%</span><sp=
an style=3D"color: rgb(0, 0, 0);"> </span><span style=3D"color: rgb(0, 102,=
 102);">4</span><span style=3D"color: rgb(102, 102, 0);">;</span><span styl=
e=3D"color: rgb(0, 0, 0);"> </span><span style=3D"color: rgb(136, 0, 0);">/=
/lvalue</span><span style=3D"color: rgb(0, 0, 0);"><br><br>cout </span><spa=
n style=3D"color: rgb(102, 102, 0);">&lt;&lt;</span><span style=3D"color: r=
gb(0, 0, 0);"> arr</span><span style=3D"color: rgb(102, 102, 0);">[</span><=
span style=3D"color: rgb(102, 0, 102);">EvaluateSpecialArrayIndex</span><sp=
an style=3D"color: rgb(102, 102, 0);">(</span><span style=3D"color: rgb(0, =
0, 0);"><wbr>a</span><span style=3D"color: rgb(102, 102, 0);">)]</span><spa=
n style=3D"color: rgb(0, 0, 0);"> </span><span style=3D"color: rgb(102, 102=
, 0);">&lt;&lt;</span><span style=3D"color: rgb(0, 0, 0);"> endl</span><spa=
n style=3D"color: rgb(102, 102, 0);">;</span><span style=3D"color: rgb(0, 0=
, 0);"> </span><span style=3D"color: rgb(136, 0, 0);">// also valid</span><=
/div></code></div><span style=3D"color: rgb(102, 102, 0); font-family: mono=
space; background-color: rgb(250, 250, 250);"><br></span>Life <a onmousedow=
n=3D"this.href=3D'http://www.google.com/url?q\75http%3A%2F%2Fmelpon.org%2Fw=
andbox%2Fpermlink%2FDLuQZd1ECewZkpxQ\46sa\75D\46sntz\0751\46usg\75AFQjCNEm_=
uIBkPSzkfBrS4_OzIA6qs4zVA';return true;" onclick=3D"this.href=3D'http://www=
..google.com/url?q\75http%3A%2F%2Fmelpon.org%2Fwandbox%2Fpermlink%2FDLuQZd1E=
CewZkpxQ\46sa\75D\46sntz\0751\46usg\75AFQjCNEm_uIBkPSzkfBrS4_OzIA6qs4zVA';r=
eturn true;" href=3D"http://melpon.org/wandbox/permlink/DLuQZd1ECewZkpxQ" t=
arget=3D"_blank">example</a>.<br><br></div><div>So this piece of code is in=
valid:</div><div><br></div><div><div style=3D"border: 1px solid rgb(187, 18=
7, 187); word-wrap: break-word; background-color: rgb(250, 250, 250);"><cod=
e><div><span style=3D"color: rgb(0, 0, 136);">constexpr</span><span style=
=3D"color: rgb(0, 0, 0);"> </span><span style=3D"color: rgb(0, 0, 136);">in=
t</span><span style=3D"color: rgb(0, 0, 0);"> </span><span style=3D"color: =
rgb(102, 0, 102);">EvaluateSpecialArrayIndex</span><span style=3D"color: rg=
b(102, 102, 0);">(</span><span style=3D"color: rgb(0, 0, 136);">int</span><=
span style=3D"color: rgb(0, 0, 0);"> a</span><span style=3D"color: rgb(102,=
 102, 0);">)</span><span style=3D"color: rgb(0, 0, 0);"><br></span><span st=
yle=3D"color: rgb(102, 102, 0);">{</span><span style=3D"color: rgb(0, 0, 0)=
;"> </span><span style=3D"color: rgb(0, 0, 136);">static_assert</span><span=
 style=3D"color: rgb(102, 102, 0);">(</span><span style=3D"color: rgb(0, 0,=
 0);"> a </span><span style=3D"color: rgb(102, 102, 0);">&lt;</span><span s=
tyle=3D"color: rgb(0, 0, 0);"> </span><span style=3D"color: rgb(0, 102, 102=
);">5</span><span style=3D"color: rgb(102, 102, 0);">,</span><span style=3D=
"color: rgb(0, 0, 0);"> </span><span style=3D"color: rgb(0, 136, 0);">"inva=
lid a"</span><span style=3D"color: rgb(0, 0, 0);"> </span><span style=3D"co=
lor: rgb(102, 102, 0);">);</span><span style=3D"color: rgb(0, 0, 0);"> </sp=
an><span style=3D"color: rgb(0, 0, 136);">return</span><span style=3D"color=
: rgb(0, 0, 0);"> a </span><span style=3D"color: rgb(102, 102, 0);">*</span=
><span style=3D"color: rgb(0, 0, 0);"> </span><span style=3D"color: rgb(0, =
0, 136);">sizeof</span><span style=3D"color: rgb(102, 102, 0);">(</span><sp=
an style=3D"color: rgb(0, 0, 136);">int</span><span style=3D"color: rgb(102=
, 102, 0);">);</span><span style=3D"color: rgb(0, 0, 0);"> </span><span sty=
le=3D"color: rgb(102, 102, 0);">}</span></div></code></div><div><br></div><=
br>Life <a onmousedown=3D"this.href=3D'http://www.google.com/url?q\75http%3=
A%2F%2Fmelpon.org%2Fwandbox%2Fpermlink%2Fz9uxsbpr9irk2LBR\46sa\75D\46sntz\0=
751\46usg\75AFQjCNFx20arc619usjmJ92iPdS3wLwRYA';return true;" onclick=3D"th=
is.href=3D'http://www.google.com/url?q\75http%3A%2F%2Fmelpon.org%2Fwandbox%=
2Fpermlink%2Fz9uxsbpr9irk2LBR\46sa\75D\46sntz\0751\46usg\75AFQjCNFx20arc619=
usjmJ92iPdS3wLwRYA';return true;" href=3D"http://melpon.org/wandbox/permlin=
k/z9uxsbpr9irk2LBR" target=3D"_blank">example</a>.</div><div><br></div><div=
>Here is where 'inline' variables came in use. They can be initialized only=
 once with another 'inline' variable or with literal but aren't 'const' and=
 non-'inline' variables can't be casted to 'inline'. However the opposite i=
s possible (casting from 'inline' to any other type). Functions declared wi=
th 'inline' parameters or return-value will be implicit 'inline' themselves=
.. Instance to a function with argument literal will first search for one wi=
th parameter of type 'inline &lt;type-of-literal&gt;'. So now we could over=
load the 'std::array::operator[]' in order to do static checks on 'inline' =
variables like this (supposing that 'templates' are still used):<br><br></d=
iv><div style=3D"border: 1px solid rgb(187, 187, 187); word-wrap: break-wor=
d; background-color: rgb(250, 250, 250);"><code><div><span style=3D"color: =
rgb(0, 0, 136);">template</span><span style=3D"color: rgb(102, 102, 0);">&l=
t;</span><span style=3D"color: rgb(0, 0, 136);">typename</span><span style=
=3D"color: rgb(0, 0, 0);"> T</span><span style=3D"color: rgb(102, 102, 0);"=
>,</span><span style=3D"color: rgb(0, 0, 0);"> size_t sz</span><span style=
=3D"color: rgb(102, 102, 0);">&gt;</span><span style=3D"color: rgb(0, 0, 0)=
;"><br>T </span><span style=3D"color: rgb(102, 102, 0);">&amp;</span><span =
style=3D"color: rgb(0, 0, 0);"> std</span><span style=3D"color: rgb(102, 10=
2, 0);">::</span><span style=3D"color: rgb(0, 0, 0);">array</span><span sty=
le=3D"color: rgb(102, 102, 0);">::</span><span style=3D"color: rgb(0, 0, 13=
6);">operator</span><span style=3D"color: rgb(102, 102, 0);">[](</span><spa=
n style=3D"color: rgb(0, 0, 0);"> size_type pos </span><span style=3D"color=
: rgb(102, 102, 0);">)</span><span style=3D"color: rgb(0, 0, 0);"><br><br><=
/span><span style=3D"color: rgb(102, 102, 0);">{</span><span style=3D"color=
: rgb(0, 0, 0);"><br>&nbsp; &nbsp; </span><span style=3D"color: rgb(0, 0, 1=
36);">static_assert</span><span style=3D"color: rgb(102, 102, 0);">(</span>=
<span style=3D"color: rgb(0, 0, 0);"> pos </span><span style=3D"color: rgb(=
102, 102, 0);">&lt;</span><span style=3D"color: rgb(0, 0, 0);"> sz</span><s=
pan style=3D"color: rgb(102, 102, 0);">,</span><span style=3D"color: rgb(0,=
 0, 0);"> </span><span style=3D"color: rgb(0, 136, 0);">"invalid array inde=
x"</span><span style=3D"color: rgb(0, 0, 0);"> </span><span style=3D"color:=
 rgb(102, 102, 0);">);</span><span style=3D"color: rgb(0, 0, 0);"><br><br>&=
nbsp; &nbsp; </span><span style=3D"color: rgb(0, 0, 136);">return</span><sp=
an style=3D"color: rgb(0, 0, 0);"> </span><span style=3D"color: rgb(0, 0, 1=
36);">this</span><span style=3D"color: rgb(102, 102, 0);">-&gt;</span><span=
 style=3D"color: rgb(0, 0, 136);">operator</span><span style=3D"color: rgb(=
102, 102, 0);">[]((</span><span style=3D"color: rgb(0, 0, 136);">int</span>=
<span style=3D"color: rgb(102, 102, 0);">)</span><span style=3D"color: rgb(=
0, 0, 0);">pos</span><span style=3D"color: rgb(102, 102, 0);">);</span><spa=
n style=3D"color: rgb(0, 0, 0);"> </span><span style=3D"color: rgb(136, 0, =
0);">//instance default 'non-inline' (run-time) operator[] with 'a' casted =
(from 'inline int') to 'int'</span><span style=3D"color: rgb(0, 0, 0);"><br=
></span><span style=3D"color: rgb(102, 102, 0);">}</span></div></code></div=
><div><span style=3D'color: rgb(0, 128, 0); line-height: 14.07px; font-fami=
ly: DejaVuSansMono,"DejaVu Sans Mono",courier,monospace; font-size: 12.8px;=
 white-space: nowrap;'><br></span></div><div><span style=3D'color: rgb(0, 1=
28, 0); line-height: 14.07px; font-family: DejaVuSansMono,"DejaVu Sans Mono=
",courier,monospace; font-size: 12.8px; white-space: nowrap;'><br></span></=
div><div>By using the above function this invalid code:<br><br><div style=
=3D"border: 1px solid rgb(187, 187, 187); word-wrap: break-word; background=
-color: rgb(250, 250, 250);"><code><div><span style=3D"color: rgb(0, 0, 0);=
">array</span><span style=3D"color: rgb(102, 102, 0);">&lt;</span><span sty=
le=3D"color: rgb(0, 0, 136);">int</span><span style=3D"color: rgb(102, 102,=
 0);">,</span><span style=3D"color: rgb(0, 0, 0);"> </span><span style=3D"c=
olor: rgb(0, 102, 102);">5</span><span style=3D"color: rgb(102, 102, 0);">&=
gt;</span><span style=3D"color: rgb(0, 0, 0);"> arr</span><span style=3D"co=
lor: rgb(102, 102, 0);">;</span><span style=3D"color: rgb(0, 0, 0);"><br>&n=
bsp; &nbsp; <br>cout </span><span style=3D"color: rgb(102, 102, 0);">&lt;&l=
t;</span><span style=3D"color: rgb(0, 0, 0);"> arr</span><span style=3D"col=
or: rgb(102, 102, 0);">[</span><span style=3D"color: rgb(0, 102, 102);">98<=
/span><span style=3D"color: rgb(102, 102, 0);">]</span><span style=3D"color=
: rgb(0, 0, 0);"> </span><span style=3D"color: rgb(102, 102, 0);">&lt;&lt;<=
/span><span style=3D"color: rgb(0, 0, 0);"> endl</span><span style=3D"color=
: rgb(102, 102, 0);">;</span></div></code></div><span style=3D"color: rgb(1=
02, 102, 0); font-family: monospace; background-color: rgb(250, 250, 250);"=
><br></span>Will report compiler error, instead of producing undefined beha=
vior.</div><div><br></div><div>The other usage of the specifier, optimizing=
 code, can be demonstrated by creating one general function - for both 'inl=
ine' and 'non-inline' parameters, of certain algorithm and other 2 for 'inl=
ine' and 'non-inline' which will specialize it, so when you call it with fo=
r example literal - it will be evaluated at compile-time and when you do wi=
th some variable it will create code for run-time execution. Example:</div>=
<div><br></div><div style=3D"border: 1px solid rgb(187, 187, 187); word-wra=
p: break-word; background-color: rgb(250, 250, 250);"><code><div><span styl=
e=3D"color: rgb(0, 0, 136);">auto</span><span style=3D"color: rgb(0, 0, 0);=
"> </span><span style=3D"color: rgb(102, 0, 102);">SomeAlgo</span><span sty=
le=3D"color: rgb(102, 102, 0);">(</span><span style=3D"color: rgb(0, 0, 136=
);">inline</span><span style=3D"color: rgb(0, 0, 0);"> </span><span style=
=3D"color: rgb(0, 0, 136);">bool</span><span style=3D"color: rgb(0, 0, 0);"=
> bIsInline</span><span style=3D"color: rgb(102, 102, 0);">,</span><span st=
yle=3D"color: rgb(0, 0, 0);"> </span><span style=3D"color: rgb(0, 0, 136);"=
>typename</span><span style=3D"color: rgb(102, 102, 0);">(</span><span styl=
e=3D"color: rgb(0, 0, 0);"> bIsInline </span><span style=3D"color: rgb(102,=
 102, 0);">?</span><span style=3D"color: rgb(0, 0, 0);"> </span><span style=
=3D"color: rgb(0, 0, 136);">inline</span><span style=3D"color: rgb(0, 0, 0)=
;"> </span><span style=3D"color: rgb(0, 0, 136);">int</span><span style=3D"=
color: rgb(0, 0, 0);"> </span><span style=3D"color: rgb(102, 102, 0);">:</s=
pan><span style=3D"color: rgb(0, 0, 0);"> </span><span style=3D"color: rgb(=
0, 0, 136);">int</span><span style=3D"color: rgb(0, 0, 0);"> </span><span s=
tyle=3D"color: rgb(102, 102, 0);">)</span><span style=3D"color: rgb(0, 0, 0=
);"> n</span><span style=3D"color: rgb(102, 102, 0);">)</span><span style=
=3D"color: rgb(0, 0, 0);"> </span><span style=3D"color: rgb(102, 102, 0);">=
-&gt;</span><span style=3D"color: rgb(0, 0, 0);"> </span><span style=3D"col=
or: rgb(0, 0, 136);">decltype</span><span style=3D"color: rgb(102, 102, 0);=
">(</span><span style=3D"color: rgb(0, 0, 0);">n</span><span style=3D"color=
: rgb(102, 102, 0);">)</span><span style=3D"color: rgb(0, 0, 0);"><br></spa=
n><span style=3D"color: rgb(102, 102, 0);">{</span><span style=3D"color: rg=
b(0, 0, 0);"><br>&nbsp; &nbsp; </span><span style=3D"color: rgb(136, 0, 0);=
">//Do something with 'n' and return 'int' (or 'inline int')</span><span st=
yle=3D"color: rgb(0, 0, 0);"><br></span><span style=3D"color: rgb(102, 102,=
 0);">}</span></div></code></div><div>&nbsp;</div></div></blockquote><block=
quote style=3D"margin: 0px 0px 0px 0.8ex; padding-left: 1ex; border-left-co=
lor: rgb(204, 204, 204); border-left-width: 1px; border-left-style: solid;"=
 class=3D"gmail_quote"><div dir=3D"ltr"><div></div><div style=3D"border: 1p=
x solid rgb(187, 187, 187); word-wrap: break-word; background-color: rgb(25=
0, 250, 250);"><code><div><span style=3D"color: rgb(0, 0, 136);">inline</sp=
an><span style=3D"color: rgb(0, 0, 0);"> </span><span style=3D"color: rgb(0=
, 0, 136);">int</span><span style=3D"color: rgb(0, 0, 0);"> </span><span st=
yle=3D"color: rgb(102, 0, 102);">SomeAlgo</span><span style=3D"color: rgb(1=
02, 102, 0);">(</span><span style=3D"color: rgb(0, 0, 136);">inline</span><=
span style=3D"color: rgb(0, 0, 0);"> </span><span style=3D"color: rgb(0, 0,=
 136);">int</span><span style=3D"color: rgb(0, 0, 0);"> a</span><span style=
=3D"color: rgb(102, 102, 0);">)</span><span style=3D"color: rgb(0, 0, 0);">=
 </span><span style=3D"color: rgb(102, 102, 0);">{</span><span style=3D"col=
or: rgb(0, 0, 0);"> </span><span style=3D"color: rgb(0, 0, 136);">static_as=
sert</span><span style=3D"color: rgb(102, 102, 0);">(</span><span style=3D"=
color: rgb(0, 0, 0);"> a </span><span style=3D"color: rgb(102, 102, 0);">&l=
t;</span><span style=3D"color: rgb(0, 0, 0);"> </span><span style=3D"color:=
 rgb(0, 102, 102);">0</span><span style=3D"color: rgb(102, 102, 0);">,</spa=
n><span style=3D"color: rgb(0, 0, 0);"> </span><span style=3D"color: rgb(0,=
 136, 0);">"invalid a"</span><span style=3D"color: rgb(0, 0, 0);"> </span><=
span style=3D"color: rgb(102, 102, 0);">);</span><span style=3D"color: rgb(=
0, 0, 0);"> </span><span style=3D"color: rgb(0, 0, 136);">return</span><spa=
n style=3D"color: rgb(0, 0, 0);"> </span><span style=3D"color: rgb(102, 0, =
102);">SomeAlgo</span><span style=3D"color: rgb(102, 102, 0);">(</span><spa=
n style=3D"color: rgb(0, 0, 136);">true</span><span style=3D"color: rgb(102=
, 102, 0);">,</span><span style=3D"color: rgb(0, 0, 0);"> a</span><span sty=
le=3D"color: rgb(102, 102, 0);">);</span><span style=3D"color: rgb(0, 0, 0)=
;"> </span><span style=3D"color: rgb(102, 102, 0);">}</span><span style=3D"=
color: rgb(0, 0, 0);"><br><br></span><span style=3D"color: rgb(0, 0, 136);"=
>int</span><span style=3D"color: rgb(0, 0, 0);"> </span><span style=3D"colo=
r: rgb(102, 0, 102);">SomeAlgo</span><span style=3D"color: rgb(102, 102, 0)=
;">(</span><span style=3D"color: rgb(0, 0, 136);">int</span><span style=3D"=
color: rgb(0, 0, 0);"> a</span><span style=3D"color: rgb(102, 102, 0);">)</=
span><span style=3D"color: rgb(0, 0, 0);"> </span><span style=3D"color: rgb=
(102, 102, 0);">{</span><span style=3D"color: rgb(0, 0, 0);"> </span><span =
style=3D"color: rgb(0, 0, 136);">return</span><span style=3D"color: rgb(0, =
0, 0);"> </span><span style=3D"color: rgb(102, 0, 102);">SomeAlgo</span><sp=
an style=3D"color: rgb(102, 102, 0);">(</span><span style=3D"color: rgb(0, =
0, 136);">false</span><span style=3D"color: rgb(102, 102, 0);">,</span><spa=
n style=3D"color: rgb(0, 0, 0);"> a</span><span style=3D"color: rgb(102, 10=
2, 0);">);</span><span style=3D"color: rgb(0, 0, 0);"> </span><span style=
=3D"color: rgb(102, 102, 0);">}</span></div></code></div><div><span style=
=3D"color: rgb(102, 0, 102); font-family: monospace; background-color: rgb(=
250, 250, 250);"><br></span><i>Note that the first function is declared as =
returning an 'inline int', if it was the function itself to be 'inline', it=
 should be 'int inline SomeAlgo', which is an inline function returning 'in=
t'.</i><span style=3D"color: rgb(102, 0, 102); font-family: monospace; back=
ground-color: rgb(250, 250, 250);"><br></span></div><div><span style=3D"col=
or: rgb(102, 0, 102); font-family: monospace; background-color: rgb(250, 25=
0, 250);"><br></span></div><div>And some example instances of 'SomeAlgo':<s=
pan style=3D"color: rgb(102, 0, 102); font-family: monospace; background-co=
lor: rgb(250, 250, 250);"><br><br></span></div><div><div style=3D"border: 1=
px solid rgb(187, 187, 187); word-wrap: break-word; background-color: rgb(2=
50, 250, 250);"><code><div><span style=3D"color: rgb(102, 0, 102);">SomeAlg=
o</span><span style=3D"color: rgb(102, 102, 0);">(</span><span style=3D"col=
or: rgb(0, 0, 0);">rand</span><span style=3D"color: rgb(102, 102, 0);">());=
</span><span style=3D"color: rgb(0, 0, 0);"> </span><span style=3D"color: r=
gb(136, 0, 0);">//it will invoke code creation as 'rand()' doesn't return '=
inline' value</span><span style=3D"color: rgb(0, 0, 0);"><br><br></span><sp=
an style=3D"color: rgb(102, 0, 102);">SomeAlgo</span><span style=3D"color: =
rgb(102, 102, 0);">(</span><span style=3D"color: rgb(0, 102, 102);">9</span=
><span style=3D"color: rgb(102, 102, 0);">);</span><span style=3D"color: rg=
b(0, 0, 0);"> </span><span style=3D"color: rgb(136, 0, 0);">//Will evaluate=
 at compile-time as literal '9' can be used to initialize 'inline' variable=
s</span></div></code></div><br>Another useful feature will be the use of 'i=
nline references' which are such that will point at some compiler-known loc=
ation (nothing special), they'll be useful when you want to create a public=
 const reference to some private member in order to allow public read-only =
access to it. For now we could only write this:<br><br><div style=3D"border=
: 1px solid rgb(187, 187, 187); word-wrap: break-word; background-color: rg=
b(250, 250, 250);"><code><div><span style=3D"color: rgb(0, 0, 136);">class<=
/span><span style=3D"color: rgb(0, 0, 0);"> A<br></span><span style=3D"colo=
r: rgb(102, 102, 0);">{</span><span style=3D"color: rgb(0, 0, 0);"><br>&nbs=
p; &nbsp; </span><span style=3D"color: rgb(0, 0, 136);">int</span><span sty=
le=3D"color: rgb(0, 0, 0);"> _a</span><span style=3D"color: rgb(102, 102, 0=
);">;</span><span style=3D"color: rgb(0, 0, 0);"><br><br></span><span style=
=3D"color: rgb(0, 0, 136);">public</span><span style=3D"color: rgb(102, 102=
, 0);">:</span><span style=3D"color: rgb(0, 0, 0);"><br><br>&nbsp; &nbsp; <=
/span><span style=3D"color: rgb(0, 0, 136);">const</span><span style=3D"col=
or: rgb(0, 0, 0);"> </span><span style=3D"color: rgb(0, 0, 136);">int</span=
><span style=3D"color: rgb(0, 0, 0);"> </span><span style=3D"color: rgb(102=
, 102, 0);">&amp;</span><span style=3D"color: rgb(0, 0, 0);">a </span><span=
 style=3D"color: rgb(102, 102, 0);">=3D</span><span style=3D"color: rgb(0, =
0, 0);"> _a</span><span style=3D"color: rgb(102, 102, 0);">;</span><span st=
yle=3D"color: rgb(0, 0, 0);"><br></span><span style=3D"color: rgb(102, 102,=
 0);">}</span><span style=3D"color: rgb(0, 0, 0);"> </span><span style=3D"c=
olor: rgb(102, 102, 0);">;</span></div></code></div><div><br></div></div><d=
iv>Life <a onmousedown=3D"this.href=3D'http://www.google.com/url?q\75http%3=
A%2F%2Fmelpon.org%2Fwandbox%2Fpermlink%2F2Ffi7NKWf86cmcQ6\46sa\75D\46sntz\0=
751\46usg\75AFQjCNHhFcfSrxn8cv6HAnNC7ZHfErXRXA';return true;" onclick=3D"th=
is.href=3D'http://www.google.com/url?q\75http%3A%2F%2Fmelpon.org%2Fwandbox%=
2Fpermlink%2F2Ffi7NKWf86cmcQ6\46sa\75D\46sntz\0751\46usg\75AFQjCNHhFcfSrxn8=
cv6HAnNC7ZHfErXRXA';return true;" href=3D"http://melpon.org/wandbox/permlin=
k/2Ffi7NKWf86cmcQ6" target=3D"_blank">example</a>.</div><div><br></div><div=
>But in the case memory for 'a' will be allocated for each 'A' instance, wh=
ich is not a deal. We couldn't write this with 'constexpr' for some strange=
 reason:<br><br><div style=3D"border: 1px solid rgb(187, 187, 187); word-wr=
ap: break-word; background-color: rgb(250, 250, 250);"><code><div><span sty=
le=3D"color: rgb(0, 0, 136);">class</span><span style=3D"color: rgb(0, 0, 0=
);"> A<br></span><span style=3D"color: rgb(102, 102, 0);">{</span><span sty=
le=3D"color: rgb(0, 0, 0);"><br>&nbsp; &nbsp; </span><span style=3D"color: =
rgb(0, 0, 136);">int</span><span style=3D"color: rgb(0, 0, 0);"> _a</span><=
span style=3D"color: rgb(102, 102, 0);">;</span><span style=3D"color: rgb(0=
, 0, 0);"><br><br></span><span style=3D"color: rgb(0, 0, 136);">public</spa=
n><span style=3D"color: rgb(102, 102, 0);">:</span><span style=3D"color: rg=
b(0, 0, 0);"><br><br>&nbsp; &nbsp; </span><span style=3D"color: rgb(0, 0, 1=
36);">constexpr</span><span style=3D"color: rgb(0, 0, 0);"> </span><span st=
yle=3D"color: rgb(0, 0, 136);">int</span><span style=3D"color: rgb(0, 0, 0)=
;"> </span><span style=3D"color: rgb(102, 102, 0);">&amp;</span><span style=
=3D"color: rgb(0, 0, 0);">a </span><span style=3D"color: rgb(102, 102, 0);"=
>=3D</span><span style=3D"color: rgb(0, 0, 0);"> _a</span><span style=3D"co=
lor: rgb(102, 102, 0);">;</span><span style=3D"color: rgb(0, 0, 0);"> </spa=
n><span style=3D"color: rgb(136, 0, 0);">// the same as 'const int &amp; co=
nstexpr a' - still produces error</span><span style=3D"color: rgb(0, 0, 0);=
"><br></span><span style=3D"color: rgb(102, 102, 0);">}</span><span style=
=3D"color: rgb(0, 0, 0);"> </span><span style=3D"color: rgb(102, 102, 0);">=
;</span></div></code></div><span style=3D"color: rgb(102, 102, 0); font-fam=
ily: monospace; background-color: rgb(250, 250, 250);"><br></span>Life <a o=
nmousedown=3D"this.href=3D'http://www.google.com/url?q\75http%3A%2F%2Fmelpo=
n.org%2Fwandbox%2Fpermlink%2FfGWsVP2bcqhG3zBa\46sa\75D\46sntz\0751\46usg\75=
AFQjCNGJ4q2ny4R_vY2UIYv3LgimaNK_0Q';return true;" onclick=3D"this.href=3D'h=
ttp://www.google.com/url?q\75http%3A%2F%2Fmelpon.org%2Fwandbox%2Fpermlink%2=
FfGWsVP2bcqhG3zBa\46sa\75D\46sntz\0751\46usg\75AFQjCNGJ4q2ny4R_vY2UIYv3Lgim=
aNK_0Q';return true;" href=3D"http://melpon.org/wandbox/permlink/fGWsVP2bcq=
hG3zBa" target=3D"_blank">example</a>.<br><br>By using our new construct th=
is could write this:<br><br><div style=3D"border: 1px solid rgb(187, 187, 1=
87); word-wrap: break-word; background-color: rgb(250, 250, 250);"><code><d=
iv><span style=3D"color: rgb(0, 0, 136);">class</span><span style=3D"color:=
 rgb(0, 0, 0);"> A<br></span><span style=3D"color: rgb(102, 102, 0);">{</sp=
an><span style=3D"color: rgb(0, 0, 0);"><br>&nbsp; &nbsp; </span><span styl=
e=3D"color: rgb(0, 0, 136);">int</span><span style=3D"color: rgb(0, 0, 0);"=
> _a</span><span style=3D"color: rgb(102, 102, 0);">;</span><span style=3D"=
color: rgb(0, 0, 0);"><br><br></span><span style=3D"color: rgb(0, 0, 136);"=
>public</span><span style=3D"color: rgb(102, 102, 0);">:</span><span style=
=3D"color: rgb(0, 0, 0);"><br><br>&nbsp; &nbsp; </span><span style=3D"color=
: rgb(0, 0, 136);">const</span><span style=3D"color: rgb(0, 0, 0);"> </span=
><span style=3D"color: rgb(0, 0, 136);">int</span><span style=3D"color: rgb=
(0, 0, 0);"> </span><span style=3D"color: rgb(102, 102, 0);">&amp;</span><s=
pan style=3D"color: rgb(0, 0, 0);"> </span><span style=3D"color: rgb(0, 0, =
136);">inline</span><span style=3D"color: rgb(0, 0, 0);"> a </span><span st=
yle=3D"color: rgb(102, 102, 0);">=3D</span><span style=3D"color: rgb(0, 0, =
0);"> _a</span><span style=3D"color: rgb(102, 102, 0);">;</span><span style=
=3D"color: rgb(0, 0, 0);"> </span><span style=3D"color: rgb(136, 0, 0);">//=
 inline reference to '_a'</span><span style=3D"color: rgb(0, 0, 0);"><br></=
span><span style=3D"color: rgb(102, 102, 0);">}</span><span style=3D"color:=
 rgb(0, 0, 0);"> </span><span style=3D"color: rgb(102, 102, 0);">;</span></=
div></code></div><span style=3D"color: rgb(102, 102, 0); font-family: monos=
pace; background-color: rgb(250, 250, 250);"><br></span>Which basically mea=
ns that each reference to 'a', will be evaluated like - '(const int)_a', so=
 no additional memory will be created now.</div><div><br></div><div>Functio=
n specialization will be done to functions with 'inline' parameters, which =
when receive argument values will search for a function which have speciali=
zed them. The parameter specialization will be done via the '=3D=3D' operat=
or (one specialization can be for multiples values). Examples<br><br></div>=
<div style=3D"border: 1px solid rgb(187, 187, 187); word-wrap: break-word; =
background-color: rgb(250, 250, 250);"><code><div><span style=3D"color: rgb=
(0, 0, 136);">auto</span><span style=3D"color: rgb(0, 0, 0);"> </span><span=
 style=3D"color: rgb(102, 0, 102);">FuncAdd</span><span style=3D"color: rgb=
(102, 102, 0);">(</span><span style=3D"color: rgb(0, 0, 136);">inline</span=
><span style=3D"color: rgb(0, 0, 0);"> </span><span style=3D"color: rgb(0, =
0, 136);">typename</span><span style=3D"color: rgb(0, 0, 0);"> T</span><spa=
n style=3D"color: rgb(102, 102, 0);">,</span><span style=3D"color: rgb(0, 0=
, 0);"> T a</span><span style=3D"color: rgb(102, 102, 0);">,</span><span st=
yle=3D"color: rgb(0, 0, 0);"> T b</span><span style=3D"color: rgb(102, 102,=
 0);">)</span><span style=3D"color: rgb(0, 0, 0);"> </span><span style=3D"c=
olor: rgb(102, 102, 0);">-&gt;</span><span style=3D"color: rgb(0, 0, 0);"> =
T </span><span style=3D"color: rgb(136, 0, 0);">//general function</span><s=
pan style=3D"color: rgb(0, 0, 0);"><br></span><span style=3D"color: rgb(102=
, 102, 0);">{</span><span style=3D"color: rgb(0, 0, 0);"><br>&nbsp; &nbsp; =
</span><span style=3D"color: rgb(0, 0, 136);">return</span><span style=3D"c=
olor: rgb(0, 0, 0);"> a </span><span style=3D"color: rgb(102, 102, 0);">+</=
span><span style=3D"color: rgb(0, 0, 0);"> b</span><span style=3D"color: rg=
b(102, 102, 0);">;</span><span style=3D"color: rgb(0, 0, 0);"><br></span><s=
pan style=3D"color: rgb(102, 102, 0);">}</span><span style=3D"color: rgb(0,=
 0, 0);"><br><br></span><span style=3D"color: rgb(0, 0, 136);">auto</span><=
span style=3D"color: rgb(0, 0, 0);"> </span><span style=3D"color: rgb(102, =
0, 102);">FuncAdd</span><span style=3D"color: rgb(102, 102, 0);">(</span><s=
pan style=3D"color: rgb(0, 0, 136);">inline</span><span style=3D"color: rgb=
(0, 0, 0);"> </span><span style=3D"color: rgb(0, 0, 136);">typename</span><=
span style=3D"color: rgb(0, 0, 0);"> T </span><span style=3D"color: rgb(102=
, 102, 0);">=3D=3D</span><span style=3D"color: rgb(0, 0, 0);"> </span><span=
 style=3D"color: rgb(0, 0, 136);">int</span><span style=3D"color: rgb(102, =
102, 0);">,</span><span style=3D"color: rgb(0, 0, 0);"> T a</span><span sty=
le=3D"color: rgb(102, 102, 0);">,</span><span style=3D"color: rgb(0, 0, 0);=
"> T b</span><span style=3D"color: rgb(102, 102, 0);">)</span><span style=
=3D"color: rgb(0, 0, 0);"> </span><span style=3D"color: rgb(102, 102, 0);">=
-&gt;</span><span style=3D"color: rgb(0, 0, 0);"> T </span><span style=3D"c=
olor: rgb(136, 0, 0);">//specialized function about the 'T' parameter, as n=
o inline params, no implicit 'inline' conversion</span><span style=3D"color=
: rgb(0, 0, 0);"><br></span><span style=3D"color: rgb(102, 102, 0);">{</spa=
n><span style=3D"color: rgb(0, 0, 0);"><br>&nbsp; &nbsp; cout </span><span =
style=3D"color: rgb(102, 102, 0);">&lt;&lt;</span><span style=3D"color: rgb=
(0, 0, 0);"> </span><span style=3D"color: rgb(0, 136, 0);">"I can deal with=
 int"</span><span style=3D"color: rgb(0, 0, 0);"> </span><span style=3D"col=
or: rgb(102, 102, 0);">&lt;&lt;</span><span style=3D"color: rgb(0, 0, 0);">=
 endl</span><span style=3D"color: rgb(102, 102, 0);">;</span><span style=3D=
"color: rgb(0, 0, 0);"><br><br>&nbsp; &nbsp; </span><span style=3D"color: r=
gb(0, 0, 136);">return</span><span style=3D"color: rgb(0, 0, 0);"> a </span=
><span style=3D"color: rgb(102, 102, 0);">+</span><span style=3D"color: rgb=
(0, 0, 0);"> b</span><span style=3D"color: rgb(102, 102, 0);">;</span><span=
 style=3D"color: rgb(0, 0, 0);"><br></span><span style=3D"color: rgb(102, 1=
02, 0);">}</span></div></code></div><div><div><br></div></div></div></block=
quote><div>Am I to understand the =E2=80=9Cinline typename T=E2=80=9D as an=
 alternative&nbsp;method of expressing templates or one function that will =
work for any type?</div><div>&nbsp;</div><div>Firstly, whether or not you w=
ant this as a template replacement, I object to having to specify the type =
when the compiler can deduce that from the variables.</div><div>&nbsp;</div=
><div>If it is meant as a replacement for a template, having the type as a =
parameter is confusing=E2=80=A6 I would expect one function, and only one f=
unction, to be substantiated when a function is not explicitly templated.</=
div><div>&nbsp;</div><div>If it is not, I am at a loss as to how a compiler=
 is meant to implement it efficiently (or at all, if it is defined in a sep=
arate TU).</div><div>&nbsp;</div><div>Regarding the second (overloaded) fun=
ction, is that supposed to overload on type int?&nbsp; If so, =E2=80=9Cauto=
 FuncAdd(int, =E2=80=A6=E2=80=9D would be more in line with current practic=
e.&nbsp; This will not create an ambiguity, as the parameter is already def=
ined as a typename.</div><div>&nbsp;</div><blockquote style=3D"margin: 0px =
0px 0px 0.8ex; padding-left: 1ex; border-left-color: rgb(204, 204, 204); bo=
rder-left-width: 1px; border-left-style: solid;" class=3D"gmail_quote"><div=
 dir=3D"ltr"><div><div>And some 'FuncAdd' instances:<br><br></div></div><di=
v style=3D"border: 1px solid rgb(187, 187, 187); word-wrap: break-word; bac=
kground-color: rgb(250, 250, 250);"><code><div><span style=3D"color: rgb(10=
2, 0, 102);">FuncAdd</span><span style=3D"color: rgb(102, 102, 0);">(</span=
><span style=3D"color: rgb(0, 0, 136);">int</span><span style=3D"color: rgb=
(102, 102, 0);">,</span><span style=3D"color: rgb(0, 0, 0);"> </span><span =
style=3D"color: rgb(0, 102, 102);">9</span><span style=3D"color: rgb(102, 1=
02, 0);">,</span><span style=3D"color: rgb(0, 0, 0);"> </span><span style=
=3D"color: rgb(0, 102, 102);">5</span><span style=3D"color: rgb(102, 102, 0=
);">);</span><span style=3D"color: rgb(0, 0, 0);"> </span><span style=3D"co=
lor: rgb(136, 0, 0);">// 'FuncAdd' int specialization called (of type - 'au=
to (inline typename T =3D=3D int, T a, T b) -&gt; T')</span><span style=3D"=
color: rgb(0, 0, 0);"><br><br></span><span style=3D"color: rgb(102, 0, 102)=
;">FuncAdd</span><span style=3D"color: rgb(102, 102, 0);">(</span><span sty=
le=3D"color: rgb(0, 0, 136);">double</span><span style=3D"color: rgb(102, 1=
02, 0);">,</span><span style=3D"color: rgb(0, 0, 0);"> </span><span style=
=3D"color: rgb(0, 102, 102);">3.14f</span><span style=3D"color: rgb(102, 10=
2, 0);">,</span><span style=3D"color: rgb(0, 0, 0);"> </span><span style=3D=
"color: rgb(0, 102, 102);">1</span><span style=3D"color: rgb(102, 102, 0);"=
>);</span><span style=3D"color: rgb(0, 0, 0);"> </span><span style=3D"color=
: rgb(136, 0, 0);">// 'FuncAdd' general called (of type - 'auto (inline typ=
ename T, T a, T b) -&gt; T')</span></div></code></div><div><br></div><div><=
br></div><div>Some additional 'inline' specifier rules connected to special=
ization and classes. A class can have special methods for 'inline' instance=
s of it, which are defined by specifiying 'inline' after it's declaration (=
in such methods 'this' will be inline pointer and will point to an sequence=
d 'inline' &nbsp;array holding it's inline member objects). Inline instance=
s of class will instance only it's special 'inline-this' methods and won't =
create any memory for it's non-inline members. Classes can't be specialized=
 but you can create a derived class which specialize their methods. But thi=
s could cha</div></div>...</blockquote></div>

<p></p>

-- <br />
<br />
--- <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 />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />

------=_Part_417_931272536.1418826323071--
------=_Part_416_1204189752.1418826323071--

.
