220 15139 <9bfdbffd-c89b-4ce1-a5e7-d679c81842c8@isocpp.org> article
Path: news.gmane.org!not-for-mail
From: sasho648 <sasho648@mail.bg>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Inline variables - superior of templates and constexpr.
Date: Tue, 16 Dec 2014 05:40:01 -0800 (PST)
Lines: 1135
Approved: news@gmane.org
Message-ID: <9bfdbffd-c89b-4ce1-a5e7-d679c81842c8@isocpp.org>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: plane.gmane.org
Mime-Version: 1.0
Content-Type: multipart/mixed; 
	boundary="----=_Part_270_847709593.1418737201599"
X-Trace: ger.gmane.org 1418877580 14441 80.91.229.3 (18 Dec 2014 04:39:40 GMT)
X-Complaints-To: usenet@ger.gmane.org
NNTP-Posting-Date: Thu, 18 Dec 2014 04:39:40 +0000 (UTC)
To: std-proposals@isocpp.org
Original-X-From: std-proposals+bncBDBNZXHN2QPRBBFVZGSAKGQEQJ2ZITY@isocpp.org Thu Dec 18 05:39:35 2014
Return-path: <std-proposals+bncBDBNZXHN2QPRBBFVZGSAKGQEQJ2ZITY@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-ie0-f199.google.com ([209.85.223.199])
	by plane.gmane.org with esmtp (Exim 4.69)
	(envelope-from <std-proposals+bncBDBNZXHN2QPRBBFVZGSAKGQEQJ2ZITY@isocpp.org>)
	id 1Y1SsA-0004Xs-B1
	for gclcip-std-proposals@m.gmane.org; Thu, 18 Dec 2014 05:39:34 +0100
Original-Received: by mail-ie0-f199.google.com with SMTP id rp18sf1662544iec.2
        for <gclcip-std-proposals@m.gmane.org>; Wed, 17 Dec 2014 20:39:33 -0800 (PST)
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: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=74PR63vhXISBjazWobhp163OLPx4rKdKiBMwtr4JfvA=;
        b=Hj2oH1Eu7UJ/K4NILilW4qIjYxZp/Fz669lNV+hcxGUSQJQ/XhHaIsUjP9DOLJIIKw
         qc1KLOEqF8mfJHt9kCZFTJOUymjHPqlhTFRDLjmpfhzdmrfCq+/GK95LFpzTP5gPqKWx
         SO68bVOA2Ai/iKtBMM+CViAohdw3TjoiYDYKhBggZhd88Cb3bLeVzNGau0R3+T5fezzx
         DsR6AlDWBMKTUXB3NcTAJs34ZiBOE1c2nIzqKyPdTqm08g8M7LTIH1RBXSFqHrCuEtgd
         kIRv1+cLAsoUjLMuJ9v1TagVLx/ncJ5lwqPjNtVV7l5Y6NBRd2WyCCn7r5oLXrWRxIfD
         FZLQ==
X-Gm-Message-State: ALoCoQkHhGgXD2DLACBN6ASXlmwNOC2OYT+QC7NjGUpACusHfwyeRJqMsTSjXS0ZyEoViDeToRFi
X-Received: by 10.50.221.104 with SMTP id qd8mr743402igc.0.1418877573374;
        Wed, 17 Dec 2014 20:39:33 -0800 (PST)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.140.37.85 with SMTP id q79ls4025474qgq.34.gmail; Wed, 17 Dec
 2014 20:39:32 -0800 (PST)
X-Received: by 10.236.20.116 with SMTP id o80mr100752yho.45.1418877572720;
        Wed, 17 Dec 2014 20:39:32 -0800 (PST)
Original-Received: by 10.224.163.71 with SMTP id z7msqax;
        Tue, 16 Dec 2014 05:40:02 -0800 (PST)
X-Received: by 10.140.37.104 with SMTP id q95mr3245qgq.36.1418737201954;
        Tue, 16 Dec 2014 05:40:01 -0800 (PST)
X-Original-Sender: sasho648@mail.bg
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:15139
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/15139>

------=_Part_270_847709593.1418737201599
Content-Type: multipart/alternative; 
	boundary="----=_Part_271_1048615353.1418737201599"

------=_Part_271_1048615353.1418737201599
Content-Type: text/plain; charset=UTF-8

'Constexpr' are very bad idea as they introduce a new keyword only to tell 
us that certain functions MAY be evaluated at compile-time (but also may 
not). Also 'constexpr' can be only whole functions and not different 
arguments, or only return-value (which would be twice more-useful). My new 
construct could deprecated templates too.

The idea is simple, variables, references or pointers declared as 'inline' 
can be constructed only once with other 'inline' variables. As 'inline' 
variable is a compiler-time known constant (can't be edited). Function with 
inline return value or arguments will be implicitly inline themselves. 
Inline classes specify that each of their members are inline (including 
functions), contain no virtual methods and 'this' is an inline pointer. If 
a class-constructor modify it's members types or size using inline 
variables known only at instance of it, then this class creates an 
incomplete type, which depending on it's construction way will create 
different classes. If a function return or arguments type depends on other 
arguments, then the function is of incomplete type, which depends on them 
and each will form the actual type. Conversion from 'inline' to any other 
type is possible but not the opposite (you can't cast to 'inline').

The main motivation for creating this new behavior for 'inline' keyword is 
enabling static checks for function arguments and also creating more 
optimized code which will calculate inline variables at compile-time and 
other ones at run-time. Examples of the first:

If we have an 'std::array', declared like this:

std::array<int, 5> arr

And we instance it like that:

cout << arr[86] << endl;

Life example <http://melpon.org/wandbox/permlink/53cTbWhdAMp8blxI>.

It will compile just fine and produce an run-time error! You'll say who 
will write this stupid code anyway but imagine that '86' is actually a call 
to 'constexpr' and we have the following code:

constexpr int EvaluateSpecialArrayIndex(int a)
{ return a * sizeof(int); }

//cout array like this

cout << arr[EvaluateSpecialArrayIndex(4)] << endl;

Life example <http://melpon.org/wandbox/permlink/3wJAm6UJgGWuUKA6>.

You'll think now - hey but I could write a static_assert in the above 
function to check if it's in array bounds but you are deadly wrong, 'int a' 
is not a 'constexpr' to write a static_assert - you are amazed now - how it 
is not a 'constexpr' as the function should be evaluated at compile-time 
but the truth is that this is not a rule, we could instance 
'EvaluateSpecialArrayIndex' fully legally with 'lvalue' also, 'constexpr' 
functions MAY be evaluated at run-time but MAY not (which depends on where 
are they instanced - if they should store their return-value into constexpr 
as in the above example, they are evaluated at compile time otherwise at 
run-time so the function should suppose that the arguments are 'lvalues') :

int a; //'lvalue'

cout << EvaluateSpecialArrayIndex(a) << endl;


Life example <http://melpon.org/wandbox/permlink/165Zoho8vNjWTPE2>.

So this is code is wrong:

constexpr int EvaluateSpecialArrayIndex(int a)
{ static_assert( a < 5, "a should be < 5"); return a * sizeof(int); }

Life example <http://melpon.org/wandbox/permlink/lrGMr2bECzpfbCxE>.


If my suggestion is accepted we could overload std::array for inline values 
as following (supposing templates are still used):

template<typename T, size_t sz>
T & std::array::operator[]( inline size_type pos )

{
    static_assert( pos < sz, "invalid array index");

    return this->operator[]((size_type)pos); //cast from 'inline size_type' 
to 'size_type' in order to instance 'operator[]' for 'lvalues'
}

And when 'inline' (or compiler known) index is accessed in array - compiler 
error will arise and so in the previous examples, this:

cout << arr[EvaluateSpecialArrayIndex(4)] << endl;

will cause an compiler error.

As I said it will also allow program explicit optimizations like for 
example the fibonacci algorithm series:

auto fibonacci_general(auto n) -> decltype(n) { 

 if (n == 0)
 {
 return 0;
 } 
 else if (n == 1)
 {
 return 1;
 }
 
 return fibonacci(n-1) + fibonacci(n-2);
}

int fibonacci(int n) { return fibonacci_general(n); } //creates and 
instance 'fibonacci_general' with lvalues ('int')

inline int fibonacci(inline int n) { static_assert( n < 0, "invalid 
parameter"); return fibonacci_general(n); } //validates param 'n', creates 
and instance 'fibonacci_general' with inline values ('inline int')

Now in the above code, depending on the value type called, the 'fibonacci' 
function will be either evaluated at compile-time or generated code for 
run-time execution. Examples:


int n;

fibonacci(n); //as 'n' is 'lvalue' fibonacci will be called at run-time

fibonacci(90); //as 'inline int' is passed 'fibonacci' will be evaluated at 
run-time

Next I'll show why 'inline' variables are the superior of templates. 
Imagine you have a class and you want one of it's member to be have public 
read-only access and private read-write one. For now you could achieve this 
only by using get/setters which are not ideal (you should always write and 
call them fro every member which is additional hassle). You could write 
this:

class A
{
int _a;

public:

const int &a = _a;
} ;

Unfortunately the above construct will always require additional 
sizeof(const int &) bytes in order to store the reference, no matter it 
will always refer the same object.

Life example <http://melpon.org/wandbox/permlink/tC85ULgy65deodZL>. 

We can not optimize this by using templates as they don't know anything 
about the 'A' members. The most equivalent code will look something like 
this:

template<public: const int &a = _a>
class A
{
int _a;
} ;

Which of-course is illegal, the same applies for 'constexpr':

class A
{
    int _a;

public:

    constexpr int &a = _a; // the same as int & constexpr a = _a;
} ;

By using my construct this could be re-written like this:

class A
{
    int _a;

public:

    int & inline a = _a; // 'a' is now by default an 'inline reference' to 
'_a'
} ;

And so now as '_a' is an inline reference all instances of 'a' will be 
replaced with something similar to '(const int)obj._a' and no run-time 
memory will be allocated.

As 'inline' will fully replace 'template''s we should talk about 'inline' 
functions and classes specializations. Every function which parameters and 
return value types depends on other inline arguments can be specialize in 
another function. Examples:

func_add(inline typename T, T a, T b) -> T
{
} //'func_add' general inline function

func_add(inline typename T == int, T a, T b) -> T
{

}//'func_add' specialization for int's - it doesn't have inline arguments 
or return-value so it's not implicitly converted into inline


Note the syntax - function specialization of argument will be done by using 
the equal sign '=='

And several example instances of 'func_add':

func_add(double, 3.14, 2); //will instance inline function

func_add(int, 3, 2); //will instance the specialized 'int' function (note 
that the '==' is different than the '=' and we can not left the first 
argument position with no value)


And the word is given to 'class' specializations. A class will be 
specialized after it's 'inline' constructor ends execution. Object being 
constructed using inline constructor, if when executed an specialization of 
the class is found it's constructor will be instanced too. Specialization 
of inline class members will be done using the 'equal' sign as the 
arguments. Example:

class A //general class
{
    T(inline typename arg) : T(arg) {}

    inline typename T;

    T data;
} ;


class A //specialized class for int's
{
    T(int arg) : data(arg) { cout << data << endl; }

    inline typename T == int;

    T data;
} ;



And if we instance an object with some int like this for example:


A obj(9);

This will happen - 'T(inline typename arg)' will be instanced, creating an 
'class A' specialization with 'int', compiler will search if there exist 
and if so it'll start using it's functionality and thus call 'T(int arg)'  
and 'cout' 9,

Now some of you will ask - so every specialization will have the same type. 
No that's not true. In the above example class 'A' is from type 'decltype(A(int{}))' 
but also from type 'A', so if there is a function using it, they could 
either be general for all 'A''s or only for the 'A''s with member 'T' of 
type 'int' like this:

void Func(A obj); //general function for objects of type 'A' thus inline

void Func(decltype(A(int{})) obj); //function of objects with specialized 
'A' type which left no inline members so function is not inline

The same applies for functions. Examples of function 'func_add':

void Func(decltype(func_add) &obj); //general function with argument of 
type 'auto (&)(inline typename T, T a, T b) -> T', as include inline 
members function implicit inline



void Func(decltype(func_add(int, int(), int())) &obj); //function with 
argument of type  'auto (&)(inline typename T == int, T a, T b) -> T', no 
inline so function isn't implicit inline

I believe this wasn't the clearest wrote of my life but I also believe you 
got the point and the benefits of including this syntax.

-- 

--- 
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 email 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-proposals/.

------=_Part_271_1048615353.1418737201599
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div>'Constexpr' are very bad idea as they introduce a new=
 keyword only to tell us that certain functions MAY be evaluated at compile=
-time (but also may not). Also 'constexpr' can be only whole functions and =
not different arguments, or only return-value (which would be twice more-us=
eful). My new construct could deprecated templates too.</div><div><br></div=
><div>The idea is simple, variables, references or pointers declared as 'in=
line' can be constructed only once with other 'inline' variables. As 'inlin=
e' variable is a compiler-time known constant (can't be edited). Function w=
ith inline return value or arguments will be implicitly inline themselves. =
Inline classes specify that each of their members are inline (including fun=
ctions), contain no virtual methods and 'this' is an inline pointer. If a c=
lass-constructor modify it's members types or size using inline variables k=
nown only at instance of it, then this class creates an incomplete type, wh=
ich depending on it's construction way will create different classes. If a =
function return or arguments type depends on other arguments, then the func=
tion is of incomplete type, which depends on them and each will form the ac=
tual type. Conversion from 'inline' to any other type is possible but not t=
he opposite (you can't cast to 'inline').<br><br>The main motivation for cr=
eating this new behavior for 'inline' keyword is enabling static checks for=
 function arguments and also creating more optimized code which will calcul=
ate inline variables at compile-time and other ones at run-time. Examples o=
f the first:<br><br>If we have an 'std::array', declared like this:<br><br>=
<div class=3D"prettyprint" style=3D"border: 1px solid rgb(187, 187, 187); w=
ord-wrap: break-word; background-color: rgb(250, 250, 250);"><code class=3D=
"prettyprint"><div class=3D"subprettyprint"><span style=3D"color: #000;" cl=
ass=3D"styled-by-prettify">std</span><span style=3D"color: #660;" class=3D"=
styled-by-prettify">::</span><span style=3D"color: #000;" class=3D"styled-b=
y-prettify">array</span><span style=3D"color: #660;" class=3D"styled-by-pre=
ttify">&lt;</span><span style=3D"color: #008;" class=3D"styled-by-prettify"=
>int</span><span style=3D"color: #660;" class=3D"styled-by-prettify">,</spa=
n><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span s=
tyle=3D"color: #066;" class=3D"styled-by-prettify">5</span><span style=3D"c=
olor: #660;" class=3D"styled-by-prettify">&gt;</span><span style=3D"color: =
#000;" class=3D"styled-by-prettify"> arr</span></div></code></div><br>And w=
e instance it like that:<br><br><span style=3D"font-family: monospace; back=
ground-color: rgb(250, 250, 250);"><div class=3D"prettyprint" style=3D"bord=
er: 1px solid rgb(187, 187, 187); word-wrap: break-word; background-color: =
rgb(250, 250, 250);"><code class=3D"prettyprint"><div class=3D"subprettypri=
nt"><span style=3D"color: #000;" class=3D"styled-by-prettify">cout </span><=
span style=3D"color: #660;" class=3D"styled-by-prettify">&lt;&lt;</span><sp=
an style=3D"color: #000;" class=3D"styled-by-prettify"> arr</span><span sty=
le=3D"color: #660;" class=3D"styled-by-prettify">[</span><span style=3D"col=
or: #066;" class=3D"styled-by-prettify">8</span><font color=3D"#006666"><sp=
an style=3D"color: #066;" class=3D"styled-by-prettify">6</span></font><span=
 style=3D"color: #660;" class=3D"styled-by-prettify">]</span><span style=3D=
"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #=
660;" class=3D"styled-by-prettify">&lt;&lt;</span><span style=3D"color: #00=
0;" class=3D"styled-by-prettify"> endl</span><span style=3D"color: #660;" c=
lass=3D"styled-by-prettify">;</span></div></code></div><div><span style=3D"=
font-family: monospace; background-color: rgb(250, 250, 250);"><br></span><=
/div>Life <a href=3D"http://melpon.org/wandbox/permlink/53cTbWhdAMp8blxI">e=
xample</a>.<br><br></span>It will compile just fine and produce an run-time=
 error! You'll say who will write this stupid code anyway but imagine that =
'86' is actually a call to 'constexpr' and we have the following code:<br><=
br></div><div class=3D"prettyprint" style=3D"border: 1px solid rgb(187, 187=
, 187); word-wrap: break-word; background-color: rgb(250, 250, 250);"><code=
 class=3D"prettyprint"><div class=3D"subprettyprint"><span style=3D"color: =
#008;" class=3D"styled-by-prettify">constexpr</span><span style=3D"color: #=
000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #008;" cla=
ss=3D"styled-by-prettify">int</span><span style=3D"color: #000;" class=3D"s=
tyled-by-prettify"> </span><span style=3D"color: #606;" class=3D"styled-by-=
prettify">EvaluateSpecialArrayIndex</span><span style=3D"color: #660;" clas=
s=3D"styled-by-prettify">(</span><span style=3D"color: #008;" class=3D"styl=
ed-by-prettify">int</span><span style=3D"color: #000;" class=3D"styled-by-p=
rettify"> a</span><span style=3D"color: #660;" class=3D"styled-by-prettify"=
>)</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br></sp=
an><span style=3D"color: #660;" class=3D"styled-by-prettify">{</span><span =
style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"=
color: #008;" class=3D"styled-by-prettify">return</span><span style=3D"colo=
r: #000;" class=3D"styled-by-prettify"> a </span><span style=3D"color: #660=
;" class=3D"styled-by-prettify">*</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> </span><span style=3D"color: #008;" class=3D"style=
d-by-prettify">sizeof</span><span style=3D"color: #660;" class=3D"styled-by=
-prettify">(</span><span style=3D"color: #008;" class=3D"styled-by-prettify=
">int</span><span style=3D"color: #660;" class=3D"styled-by-prettify">);</s=
pan><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span=
 style=3D"color: #660;" class=3D"styled-by-prettify">}</span><span style=3D=
"color: #000;" class=3D"styled-by-prettify"><br><br></span><span style=3D"c=
olor: #800;" class=3D"styled-by-prettify">//cout array like this</span><spa=
n style=3D"color: #000;" class=3D"styled-by-prettify"><br><br>cout </span><=
span style=3D"color: #660;" class=3D"styled-by-prettify">&lt;&lt;</span><sp=
an style=3D"color: #000;" class=3D"styled-by-prettify"> arr</span><span sty=
le=3D"color: #660;" class=3D"styled-by-prettify">[</span><span style=3D"fon=
t-family: Arial, Helvetica, sans-serif;"><span style=3D"color: #606;" class=
=3D"styled-by-prettify">EvaluateSpecialArrayIndex</span><span style=3D"colo=
r: #660;" class=3D"styled-by-prettify">(</span><font color=3D"#006666"><spa=
n style=3D"color: #066;" class=3D"styled-by-prettify">4</span></font></span=
><font color=3D"#006666" style=3D"font-family: Arial, Helvetica, sans-serif=
;"><span style=3D"color: #660;" class=3D"styled-by-prettify">)</span></font=
><span style=3D"color: #660;" class=3D"styled-by-prettify">]</span><span st=
yle=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"co=
lor: #660;" class=3D"styled-by-prettify">&lt;&lt;</span><span style=3D"colo=
r: #000;" class=3D"styled-by-prettify"> endl</span><span style=3D"color: #6=
60;" class=3D"styled-by-prettify">;</span></div></code></div><div><br></div=
><div>Life <a href=3D"http://melpon.org/wandbox/permlink/3wJAm6UJgGWuUKA6">=
example</a>.</div><div><br></div><div>You'll think now - hey but I could wr=
ite a static_assert in the above function to check if it's in array bounds =
but you are deadly wrong, 'int a' is not a 'constexpr' to write a static_as=
sert - you are amazed now - how it is not a 'constexpr' as the function sho=
uld be evaluated at compile-time but the truth is that this is not a rule, =
we could instance 'EvaluateSpecialArrayIndex' fully legally with 'lvalue' a=
lso, 'constexpr' functions MAY be evaluated at run-time but MAY not (which =
depends on where are they instanced - if they should store their return-val=
ue into constexpr as in the above example, they are evaluated at compile ti=
me otherwise at run-time so the function should suppose that the arguments =
are 'lvalues') :</div><div><br></div><div><div class=3D"prettyprint" style=
=3D"border: 1px solid rgb(187, 187, 187); word-wrap: break-word; background=
-color: rgb(250, 250, 250);"><code class=3D"prettyprint"><div class=3D"subp=
rettyprint"><span style=3D"color: #008;" class=3D"styled-by-prettify">int</=
span><span style=3D"color: #000;" class=3D"styled-by-prettify"> a</span><sp=
an style=3D"color: #660;" class=3D"styled-by-prettify">;</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color=
: #800;" class=3D"styled-by-prettify">//'lvalue'</span><span style=3D"color=
: #000;" class=3D"styled-by-prettify"><br><br>cout </span><span style=3D"co=
lor: #660;" class=3D"styled-by-prettify">&lt;&lt;</span><span style=3D"colo=
r: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #606;"=
 class=3D"styled-by-prettify">EvaluateSpecialArrayIndex</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">(</span><span style=3D"color=
: #000;" class=3D"styled-by-prettify">a</span><span style=3D"color: #660;" =
class=3D"styled-by-prettify">)</span><span style=3D"color: #000;" class=3D"=
styled-by-prettify"> </span><span style=3D"color: #660;" class=3D"styled-by=
-prettify">&lt;&lt;</span><span style=3D"color: #000;" class=3D"styled-by-p=
rettify"> endl</span><span style=3D"color: #660;" class=3D"styled-by-pretti=
fy">;</span></div></code></div><span style=3D"color: rgb(102, 0, 102); back=
ground-color: rgb(250, 250, 250);"><br></span><br>Life <a href=3D"http://me=
lpon.org/wandbox/permlink/165Zoho8vNjWTPE2">example</a>.</div><div><br></di=
v><div>So this is code is wrong:<br><br><div class=3D"prettyprint" style=3D=
"border: 1px solid rgb(187, 187, 187); word-wrap: break-word; background-co=
lor: rgb(250, 250, 250);"><code class=3D"prettyprint"><div class=3D"subpret=
typrint"><span style=3D"color: #008;" class=3D"styled-by-prettify">constexp=
r</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><=
span style=3D"color: #008;" class=3D"styled-by-prettify">int</span><span st=
yle=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"co=
lor: #606;" class=3D"styled-by-prettify">EvaluateSpecialArrayIndex</span><s=
pan style=3D"color: #660;" class=3D"styled-by-prettify">(</span><span style=
=3D"color: #008;" class=3D"styled-by-prettify">int</span><span style=3D"col=
or: #000;" class=3D"styled-by-prettify"> a</span><span style=3D"color: #660=
;" class=3D"styled-by-prettify">)</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"><br></span><span style=3D"color: #660;" class=3D"st=
yled-by-prettify">{</span><span style=3D"color: #000;" class=3D"styled-by-p=
rettify"> </span><span style=3D"color: #008;" class=3D"styled-by-prettify">=
static_assert</span><span style=3D"color: #660;" class=3D"styled-by-prettif=
y">(</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> a </s=
pan><span style=3D"color: #660;" class=3D"styled-by-prettify">&lt;</span><s=
pan style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=
=3D"color: #066;" class=3D"styled-by-prettify">5</span><span style=3D"color=
: #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">"a should be &lt; 5"</span><span style=3D"color: #660;"=
 class=3D"styled-by-prettify">);</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> </span><span style=3D"color: #008;" class=3D"style=
d-by-prettify">return</span><span style=3D"color: #000;" class=3D"styled-by=
-prettify"> a </span><span style=3D"color: #660;" class=3D"styled-by-pretti=
fy">*</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </sp=
an><span style=3D"color: #008;" class=3D"styled-by-prettify">sizeof</span><=
span style=3D"color: #660;" class=3D"styled-by-prettify">(</span><span styl=
e=3D"color: #008;" class=3D"styled-by-prettify">int</span><span style=3D"co=
lor: #660;" class=3D"styled-by-prettify">);</span><span style=3D"color: #00=
0;" class=3D"styled-by-prettify"> </span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">}</span></div></code></div><div><font color=3D"#000=
088" face=3D"monospace"><br></font></div>Life <a href=3D"http://melpon.org/=
wandbox/permlink/lrGMr2bECzpfbCxE">example</a>.</div><div><br></div><div><b=
r></div><div>If my suggestion is accepted we could overload std::array for =
inline values as following (supposing templates are still used):<br><br></d=
iv><div class=3D"prettyprint" style=3D"border: 1px solid rgb(187, 187, 187)=
; word-wrap: break-word; background-color: rgb(250, 250, 250);"><code class=
=3D"prettyprint"><div class=3D"subprettyprint"><span style=3D"color: #008;"=
 class=3D"styled-by-prettify">template</span><span style=3D"color: #660;" c=
lass=3D"styled-by-prettify">&lt;</span><span style=3D"color: #008;" class=
=3D"styled-by-prettify">typename</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> T</span><span style=3D"color: #660;" class=3D"styl=
ed-by-prettify">,</span><span style=3D"color: #000;" class=3D"styled-by-pre=
ttify"> size_t sz</span><span style=3D"color: #660;" class=3D"styled-by-pre=
ttify">&gt;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"=
><br>T </span><span style=3D"color: #660;" class=3D"styled-by-prettify">&am=
p;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> std</sp=
an><span style=3D"color: #660;" class=3D"styled-by-prettify">::</span><span=
 style=3D"color: #000;" class=3D"styled-by-prettify">array</span><span styl=
e=3D"color: #660;" class=3D"styled-by-prettify">::</span><span style=3D"col=
or: #008;" class=3D"styled-by-prettify">operator</span><span style=3D"color=
: #660;" class=3D"styled-by-prettify">[](</span><span style=3D"color: #000;=
" class=3D"styled-by-prettify"> </span><span style=3D"color: #008;" class=
=3D"styled-by-prettify">inline</span><span style=3D"color: #000;" class=3D"=
styled-by-prettify"> size_type pos </span><span style=3D"color: #660;" clas=
s=3D"styled-by-prettify">)</span><span style=3D"color: #000;" class=3D"styl=
ed-by-prettify"><br><br></span><span style=3D"color: #660;" class=3D"styled=
-by-prettify">{</span><span style=3D"color: #000;" class=3D"styled-by-prett=
ify"><br>&nbsp; &nbsp; </span><span style=3D"color: #008;" class=3D"styled-=
by-prettify">static_assert</span><span style=3D"color: #660;" class=3D"styl=
ed-by-prettify">(</span><span style=3D"color: #000;" class=3D"styled-by-pre=
ttify"> pos </span><span style=3D"color: #660;" class=3D"styled-by-prettify=
">&lt;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> sz<=
/span><span style=3D"color: #660;" class=3D"styled-by-prettify">,</span><sp=
an style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=
=3D"color: #080;" class=3D"styled-by-prettify">"invalid array index"</span>=
<span style=3D"color: #660;" class=3D"styled-by-prettify">);</span><span st=
yle=3D"color: #000;" class=3D"styled-by-prettify"><br><br>&nbsp; &nbsp; </s=
pan><span style=3D"color: #008;" class=3D"styled-by-prettify">return</span>=
<span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span sty=
le=3D"color: #008;" class=3D"styled-by-prettify">this</span><span style=3D"=
color: #660;" class=3D"styled-by-prettify">-&gt;</span><span style=3D"color=
: #008;" class=3D"styled-by-prettify">operator</span><span style=3D"color: =
#660;" class=3D"styled-by-prettify">[]((</span><span style=3D"color: #000;"=
 class=3D"styled-by-prettify">size_type</span><span style=3D"color: #660;" =
class=3D"styled-by-prettify">)</span><span style=3D"color: #000;" class=3D"=
styled-by-prettify">pos</span><span style=3D"color: #660;" class=3D"styled-=
by-prettify">);</span><span style=3D"color: #000;" class=3D"styled-by-prett=
ify"> </span><span style=3D"color: #800;" class=3D"styled-by-prettify">//ca=
st from 'inline size_type' to 'size_type' in order to instance 'operator[]'=
 for 'lvalues'</span><span style=3D"color: #000;" class=3D"styled-by-pretti=
fy"><br></span><span style=3D"color: #660;" class=3D"styled-by-prettify">}<=
/span></div></code></div><div><span class=3D"br0" style=3D"line-height: 14.=
0799999237061px; font-family: DejaVuSansMono, 'DejaVu Sans Mono', courier, =
monospace; font-size: 12.8000001907349px; white-space: nowrap;"><font color=
=3D"#008080"><br></font></span></div><div>And when 'inline' (or compiler kn=
own) index is accessed in array - compiler error will arise and so in the p=
revious examples, this:<br><br><div class=3D"prettyprint" style=3D"border: =
1px solid rgb(187, 187, 187); word-wrap: break-word; background-color: rgb(=
250, 250, 250);"><code class=3D"prettyprint"><div class=3D"subprettyprint">=
<span style=3D"color: #000;" class=3D"styled-by-prettify">cout </span><span=
 style=3D"color: #660;" class=3D"styled-by-prettify">&lt;&lt;</span><span s=
tyle=3D"color: #000;" class=3D"styled-by-prettify"> arr</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">[</span><span style=3D"color=
: #606;" class=3D"styled-by-prettify">EvaluateSpecialArrayIndex</span><span=
 style=3D"color: #660;" class=3D"styled-by-prettify">(</span><span style=3D=
"color: #066;" class=3D"styled-by-prettify">4</span><span style=3D"color: #=
660;" class=3D"styled-by-prettify">)]</span><span style=3D"color: #000;" cl=
ass=3D"styled-by-prettify"> </span><span style=3D"color: #660;" class=3D"st=
yled-by-prettify">&lt;&lt;</span><span style=3D"color: #000;" class=3D"styl=
ed-by-prettify"> endl</span><span style=3D"color: #660;" class=3D"styled-by=
-prettify">;</span></div></code></div><span class=3D"styled-by-prettify" st=
yle=3D"font-family: monospace; color: rgb(102, 102, 0); background-color: r=
gb(250, 250, 250);"><br></span>will cause an compiler error.</div><div><br>=
</div><div>As I said it will also allow program explicit optimizations like=
 for example the fibonacci algorithm series:<br><br></div><div><div class=
=3D"prettyprint" style=3D"border: 1px solid rgb(187, 187, 187); word-wrap: =
break-word; background-color: rgb(250, 250, 250);"><code class=3D"prettypri=
nt"><div class=3D"subprettyprint"><span style=3D"color: #008;" class=3D"sty=
led-by-prettify">auto</span><span style=3D"color: #000;" class=3D"styled-by=
-prettify"> fibonacci_general</span><span style=3D"color: #660;" class=3D"s=
tyled-by-prettify">(</span><span style=3D"color: #008;" class=3D"styled-by-=
prettify">auto</span><span style=3D"color: #000;" class=3D"styled-by-pretti=
fy"> n</span><span style=3D"color: #660;" class=3D"styled-by-prettify">)</s=
pan><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span=
 style=3D"color: #660;" class=3D"styled-by-prettify">-&gt;</span><span styl=
e=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"colo=
r: #008;" class=3D"styled-by-prettify">decltype</span><span style=3D"color:=
 #660;" class=3D"styled-by-prettify">(</span><span style=3D"color: #000;" c=
lass=3D"styled-by-prettify">n</span><span style=3D"color: #660;" class=3D"s=
tyled-by-prettify">)</span><span style=3D"color: #000;" class=3D"styled-by-=
prettify"> </span><span style=3D"color: #660;" class=3D"styled-by-prettify"=
>{</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> <br><br=
>&nbsp;</span><span style=3D"color: #008;" class=3D"styled-by-prettify">if<=
/span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><sp=
an style=3D"color: #660;" class=3D"styled-by-prettify">(</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify">n </span><span style=3D"colo=
r: #660;" class=3D"styled-by-prettify">=3D=3D</span><span style=3D"color: #=
000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #066;" cla=
ss=3D"styled-by-prettify">0</span><span style=3D"color: #660;" class=3D"sty=
led-by-prettify">)</span><span style=3D"color: #000;" class=3D"styled-by-pr=
ettify"><br>&nbsp;</span><span style=3D"color: #660;" class=3D"styled-by-pr=
ettify">{</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><=
br>&nbsp;</span><span style=3D"color: #008;" class=3D"styled-by-prettify">r=
eturn</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </sp=
an><span style=3D"color: #066;" class=3D"styled-by-prettify">0</span><span =
style=3D"color: #660;" class=3D"styled-by-prettify">;</span><span style=3D"=
color: #000;" class=3D"styled-by-prettify"><br>&nbsp;</span><span style=3D"=
color: #660;" class=3D"styled-by-prettify">}</span><span style=3D"color: #0=
00;" class=3D"styled-by-prettify"> <br>&nbsp;</span><span style=3D"color: #=
008;" class=3D"styled-by-prettify">else</span><span style=3D"color: #000;" =
class=3D"styled-by-prettify"> </span><span style=3D"color: #008;" class=3D"=
styled-by-prettify">if</span><span style=3D"color: #000;" class=3D"styled-b=
y-prettify"> </span><span style=3D"color: #660;" class=3D"styled-by-prettif=
y">(</span><span style=3D"color: #000;" class=3D"styled-by-prettify">n </sp=
an><span style=3D"color: #660;" class=3D"styled-by-prettify">=3D=3D</span><=
span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span styl=
e=3D"color: #066;" class=3D"styled-by-prettify">1</span><span style=3D"colo=
r: #660;" class=3D"styled-by-prettify">)</span><span style=3D"color: #000;"=
 class=3D"styled-by-prettify"><br>&nbsp;</span><span style=3D"color: #660;"=
 class=3D"styled-by-prettify">{</span><span style=3D"color: #000;" class=3D=
"styled-by-prettify"><br>&nbsp;</span><span style=3D"color: #008;" class=3D=
"styled-by-prettify">return</span><span style=3D"color: #000;" class=3D"sty=
led-by-prettify"> </span><span style=3D"color: #066;" class=3D"styled-by-pr=
ettify">1</span><span style=3D"color: #660;" class=3D"styled-by-prettify">;=
</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>&nbsp;=
</span><span style=3D"color: #660;" class=3D"styled-by-prettify">}</span><s=
pan style=3D"color: #000;" class=3D"styled-by-prettify"><br>&nbsp;<br>&nbsp=
;</span><span style=3D"color: #008;" class=3D"styled-by-prettify">return</s=
pan><span style=3D"color: #000;" class=3D"styled-by-prettify"> fibonacci</s=
pan><span style=3D"color: #660;" class=3D"styled-by-prettify">(</span><span=
 style=3D"color: #000;" class=3D"styled-by-prettify">n</span><span style=3D=
"color: #660;" class=3D"styled-by-prettify">-</span><span style=3D"color: #=
066;" class=3D"styled-by-prettify">1</span><span style=3D"color: #660;" cla=
ss=3D"styled-by-prettify">)</span><span style=3D"color: #000;" class=3D"sty=
led-by-prettify"> </span><span style=3D"color: #660;" class=3D"styled-by-pr=
ettify">+</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> =
fibonacci</span><span style=3D"color: #660;" class=3D"styled-by-prettify">(=
</span><span style=3D"color: #000;" class=3D"styled-by-prettify">n</span><s=
pan style=3D"color: #660;" class=3D"styled-by-prettify">-</span><span style=
=3D"color: #066;" class=3D"styled-by-prettify">2</span><span style=3D"color=
: #660;" class=3D"styled-by-prettify">);</span><span style=3D"color: #000;"=
 class=3D"styled-by-prettify"><br></span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">}</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify"><br><br></span><span style=3D"color: #008;" class=3D"styled-=
by-prettify">int</span><span style=3D"color: #000;" class=3D"styled-by-pret=
tify"> fibonacci</span><span style=3D"color: #660;" class=3D"styled-by-pret=
tify">(</span><span style=3D"color: #008;" class=3D"styled-by-prettify">int=
</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> n</span><=
span style=3D"color: #660;" class=3D"styled-by-prettify">)</span><span styl=
e=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"colo=
r: #660;" class=3D"styled-by-prettify">{</span><span style=3D"color: #000;"=
 class=3D"styled-by-prettify"> </span><span style=3D"color: #008;" class=3D=
"styled-by-prettify">return</span><span style=3D"color: #000;" class=3D"sty=
led-by-prettify"> fibonacci_general</span><span style=3D"color: #660;" clas=
s=3D"styled-by-prettify">(</span><span style=3D"color: #000;" class=3D"styl=
ed-by-prettify">n</span><span style=3D"color: #660;" class=3D"styled-by-pre=
ttify">);</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> =
</span><span style=3D"color: #660;" class=3D"styled-by-prettify">}</span><s=
pan style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=
=3D"color: #800;" class=3D"styled-by-prettify">//creates and instance 'fibo=
nacci_general' with lvalues ('int')</span><span style=3D"color: #000;" clas=
s=3D"styled-by-prettify"><br><br></span><span style=3D"color: #008;" class=
=3D"styled-by-prettify">inline</span><span style=3D"color: #000;" class=3D"=
styled-by-prettify"> </span><span style=3D"color: #008;" class=3D"styled-by=
-prettify">int</span><span style=3D"color: #000;" class=3D"styled-by-pretti=
fy"> fibonacci</span><span style=3D"color: #660;" class=3D"styled-by-pretti=
fy">(</span><span style=3D"color: #008;" class=3D"styled-by-prettify">inlin=
e</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><=
span style=3D"color: #008;" class=3D"styled-by-prettify">int</span><span st=
yle=3D"color: #000;" class=3D"styled-by-prettify"> n</span><span style=3D"c=
olor: #660;" class=3D"styled-by-prettify">)</span><span style=3D"color: #00=
0;" class=3D"styled-by-prettify"> </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">static_assert</span><span style=3D"color: #660;" class=3D"styled-by-p=
rettify">(</span><span style=3D"color: #000;" class=3D"styled-by-prettify">=
 n </span><span style=3D"color: #660;" class=3D"styled-by-prettify">&lt;</s=
pan><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span=
 style=3D"color: #066;" class=3D"styled-by-prettify">0</span><span style=3D=
"color: #660;" class=3D"styled-by-prettify">,</span><span style=3D"color: #=
000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #080;" cla=
ss=3D"styled-by-prettify">"invalid parameter"</span><span style=3D"color: #=
660;" class=3D"styled-by-prettify">);</span><span style=3D"color: #000;" cl=
ass=3D"styled-by-prettify"> </span><span style=3D"color: #008;" class=3D"st=
yled-by-prettify">return</span><span style=3D"color: #000;" class=3D"styled=
-by-prettify"> fibonacci_general</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">(</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify">n</span><span style=3D"color: #660;" class=3D"styled-by-pret=
tify">);</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> <=
/span><span style=3D"color: #660;" class=3D"styled-by-prettify">}</span><sp=
an style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=
=3D"color: #800;" class=3D"styled-by-prettify">//validates param 'n', creat=
es and instance 'fibonacci_general' with inline values ('inline int')</span=
></div></code></div><span style=3D"color: rgb(136, 0, 0); background-color:=
 rgb(250, 250, 250);"><span class=3D"styled-by-prettify"><br></span><span c=
lass=3D"styled-by-prettify" style=3D"color: rgb(0, 0, 0);">Now in the above=
 code, depending on the value type called, the '</span></span><span style=
=3D"color: rgb(0, 0, 0); font-family: monospace; background-color: rgb(250,=
 250, 250);">fibonacci</span><span style=3D"color: rgb(0, 0, 0); background=
-color: rgb(250, 250, 250);">' function will be either evaluated at compile=
-time or generated code for run-time execution. Examples:<br><br><br></span=
></div><div class=3D"prettyprint" style=3D"border: 1px solid rgb(187, 187, =
187); word-wrap: break-word; background-color: rgb(250, 250, 250);"><code c=
lass=3D"prettyprint"><div class=3D"subprettyprint"><span style=3D"color: #0=
08;" class=3D"styled-by-prettify">int</span><span style=3D"color: #000;" cl=
ass=3D"styled-by-prettify"> n</span><span style=3D"color: #660;" class=3D"s=
tyled-by-prettify">;</span><span style=3D"color: #000;" class=3D"styled-by-=
prettify"><br><br>fibonacci</span><span style=3D"color: #660;" class=3D"sty=
led-by-prettify">(</span><span style=3D"color: #000;" class=3D"styled-by-pr=
ettify">n</span><span style=3D"color: #660;" class=3D"styled-by-prettify">)=
;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><=
span style=3D"color: #800;" class=3D"styled-by-prettify">//as 'n' is 'lvalu=
e' fibonacci will be called at run-time</span><span style=3D"color: #000;" =
class=3D"styled-by-prettify"><br><br>fibonacci</span><span style=3D"color: =
#660;" class=3D"styled-by-prettify">(</span><span style=3D"color: #066;" cl=
ass=3D"styled-by-prettify">90</span><span style=3D"color: #660;" class=3D"s=
tyled-by-prettify">);</span><span style=3D"color: #000;" class=3D"styled-by=
-prettify"> </span><span style=3D"color: #800;" class=3D"styled-by-prettify=
">//as 'inline int' is passed 'fibonacci' will be evaluated at run-time</sp=
an></div></code></div><div><span style=3D"color: rgb(0, 0, 0); font-family:=
 monospace; background-color: rgb(250, 250, 250);"><br></span></div><div>Ne=
xt I'll show why 'inline' variables are the superior of templates. Imagine =
you have a class and you want one of it's member to be have public read-onl=
y access and private read-write one. For now you could achieve this only by=
 using get/setters which are not ideal (you should always write and call th=
em fro every member which is additional hassle). You could write this:<br><=
br></div><div class=3D"prettyprint" style=3D"border: 1px solid rgb(187, 187=
, 187); word-wrap: break-word; background-color: rgb(250, 250, 250);"><code=
 class=3D"prettyprint"><div class=3D"subprettyprint"><span style=3D"color: =
#008;" class=3D"styled-by-prettify">class</span><span style=3D"color: #000;=
" class=3D"styled-by-prettify"> A<br></span><span style=3D"color: #660;" cl=
ass=3D"styled-by-prettify">{</span><span style=3D"color: #000;" class=3D"st=
yled-by-prettify"><br></span><span style=3D"color: #008;" class=3D"styled-b=
y-prettify">int</span><span style=3D"color: #000;" class=3D"styled-by-prett=
ify"> _a</span><span style=3D"color: #660;" class=3D"styled-by-prettify">;<=
/span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br><br></s=
pan><span style=3D"color: #008;" class=3D"styled-by-prettify">public</span>=
<span style=3D"color: #660;" class=3D"styled-by-prettify">:</span><span sty=
le=3D"color: #000;" class=3D"styled-by-prettify"><br><br></span><span style=
=3D"color: #008;" class=3D"styled-by-prettify">const</span><span style=3D"c=
olor: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #00=
8;" class=3D"styled-by-prettify">int</span><span style=3D"color: #000;" cla=
ss=3D"styled-by-prettify"> </span><span style=3D"color: #660;" class=3D"sty=
led-by-prettify">&amp;</span><span style=3D"color: #000;" class=3D"styled-b=
y-prettify">a </span><span style=3D"color: #660;" class=3D"styled-by-pretti=
fy">=3D</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> _a=
</span><span style=3D"color: #660;" class=3D"styled-by-prettify">;</span><s=
pan style=3D"color: #000;" class=3D"styled-by-prettify"><br></span><span st=
yle=3D"color: #660;" class=3D"styled-by-prettify">}</span><span style=3D"co=
lor: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #660=
;" class=3D"styled-by-prettify">;</span></div></code></div><div><br></div><=
div>Unfortunately the above construct will always require additional sizeof=
(const int &amp;) bytes in order to store the reference, no matter it will =
always refer the same object.</div><div><br></div><div>Life <a href=3D"http=
://melpon.org/wandbox/permlink/tC85ULgy65deodZL">example</a>.&nbsp;</div><d=
iv><br></div><div>We can not optimize this by using templates as they don't=
 know anything about the 'A' members. The most equivalent code will look so=
mething like this:<br><br><div class=3D"prettyprint" style=3D"border: 1px s=
olid rgb(187, 187, 187); word-wrap: break-word; background-color: rgb(250, =
250, 250);"><code class=3D"prettyprint"><div class=3D"subprettyprint"><span=
 style=3D"color: #008;" class=3D"styled-by-prettify">template</span><span s=
tyle=3D"color: #660;" class=3D"styled-by-prettify">&lt;</span><span style=
=3D"color: #008;" class=3D"styled-by-prettify">public</span><span style=3D"=
color: #660;" class=3D"styled-by-prettify">:</span><span style=3D"color: #0=
00;" class=3D"styled-by-prettify"> </span><span style=3D"color: #008;" clas=
s=3D"styled-by-prettify">const</span><span style=3D"color: #000;" class=3D"=
styled-by-prettify"> </span><span style=3D"color: #008;" class=3D"styled-by=
-prettify">int</span><span style=3D"color: #000;" class=3D"styled-by-pretti=
fy"> </span><span style=3D"color: #660;" class=3D"styled-by-prettify">&amp;=
</span><span style=3D"color: #000;" class=3D"styled-by-prettify">a </span><=
span style=3D"color: #660;" class=3D"styled-by-prettify">=3D</span><span st=
yle=3D"color: #000;" class=3D"styled-by-prettify"> _a</span><span style=3D"=
color: #660;" class=3D"styled-by-prettify">&gt;</span><span style=3D"color:=
 #000;" class=3D"styled-by-prettify"><br></span><span style=3D"color: #008;=
" class=3D"styled-by-prettify">class</span><span style=3D"color: #000;" cla=
ss=3D"styled-by-prettify"> A<br></span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">{</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify"><br></span><span style=3D"color: #008;" class=3D"styled-by-p=
rettify">int</span><span style=3D"color: #000;" class=3D"styled-by-prettify=
"> _a</span><span style=3D"color: #660;" class=3D"styled-by-prettify">;</sp=
an><span style=3D"color: #000;" class=3D"styled-by-prettify"><br></span><sp=
an style=3D"color: #660;" class=3D"styled-by-prettify">}</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color=
: #660;" class=3D"styled-by-prettify">;</span></div></code></div><span clas=
s=3D"styled-by-prettify" style=3D"font-family: monospace; color: rgb(102, 1=
02, 0); background-color: rgb(250, 250, 250);"><br></span>Which of-course i=
s illegal, the same applies for 'constexpr':</div><div><br></div><div><div =
class=3D"prettyprint" style=3D"border: 1px solid rgb(187, 187, 187); word-w=
rap: break-word; background-color: rgb(250, 250, 250);"><code class=3D"pret=
typrint"><div class=3D"subprettyprint"><span style=3D"color: #008;" class=
=3D"styled-by-prettify">class</span><span style=3D"color: #000;" class=3D"s=
tyled-by-prettify"> A<br></span><span style=3D"color: #660;" class=3D"style=
d-by-prettify">{</span><span style=3D"color: #000;" class=3D"styled-by-pret=
tify"><br>&nbsp; &nbsp; </span><span style=3D"color: #008;" class=3D"styled=
-by-prettify">int</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"><br><br><=
/span><span style=3D"color: #008;" class=3D"styled-by-prettify">public</spa=
n><span style=3D"color: #660;" class=3D"styled-by-prettify">:</span><span s=
tyle=3D"color: #000;" class=3D"styled-by-prettify"><br><br>&nbsp; &nbsp; </=
span><span style=3D"color: #008;" class=3D"styled-by-prettify">constexpr</s=
pan><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span=
 style=3D"color: #008;" class=3D"styled-by-prettify">int</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color=
: #660;" class=3D"styled-by-prettify">&amp;</span><span style=3D"color: #00=
0;" class=3D"styled-by-prettify">a </span><span style=3D"color: #660;" clas=
s=3D"styled-by-prettify">=3D</span><span style=3D"color: #000;" class=3D"st=
yled-by-prettify"> _a</span><span style=3D"color: #660;" class=3D"styled-by=
-prettify">;</span><span style=3D"color: #000;" class=3D"styled-by-prettify=
"> </span><span style=3D"color: #800;" class=3D"styled-by-prettify">// the =
same as int &amp;&nbsp;</span><span style=3D"color: rgb(136, 0, 0); font-fa=
mily: Arial, Helvetica, sans-serif;">constexpr&nbsp;</span><span style=3D"c=
olor: rgb(136, 0, 0); font-family: Arial, Helvetica, sans-serif;">a =3D _a;=
</span></div><div class=3D"subprettyprint"><span style=3D"color: #660;" cla=
ss=3D"styled-by-prettify">}</span><span style=3D"color: #000;" class=3D"sty=
led-by-prettify"> </span><span style=3D"color: #660;" class=3D"styled-by-pr=
ettify">;</span></div></code></div><div><br>By using my construct this coul=
d be re-written like this:<br><br><div class=3D"prettyprint" style=3D"borde=
r: 1px solid rgb(187, 187, 187); word-wrap: break-word; background-color: r=
gb(250, 250, 250);"><code class=3D"prettyprint"><div class=3D"subprettyprin=
t"><span style=3D"color: #008;" class=3D"styled-by-prettify">class</span><s=
pan style=3D"color: #000;" class=3D"styled-by-prettify"> A<br></span><span =
style=3D"color: #660;" class=3D"styled-by-prettify">{</span><span style=3D"=
color: #000;" class=3D"styled-by-prettify"><br>&nbsp; &nbsp; </span><span s=
tyle=3D"color: #008;" class=3D"styled-by-prettify">int</span><span style=3D=
"color: #000;" class=3D"styled-by-prettify"> _a</span><span style=3D"color:=
 #660;" class=3D"styled-by-prettify">;</span><span style=3D"color: #000;" c=
lass=3D"styled-by-prettify"><br><br></span><span style=3D"color: #008;" cla=
ss=3D"styled-by-prettify">public</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">:</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify"><br><br>&nbsp; &nbsp; </span><span style=3D"color: #008;" cl=
ass=3D"styled-by-prettify">int</span><span style=3D"color: #000;" class=3D"=
styled-by-prettify"> </span><span style=3D"color: #660;" class=3D"styled-by=
-prettify">&amp;</span><span style=3D"color: #000;" class=3D"styled-by-pret=
tify"> </span><span style=3D"color: #008;" class=3D"styled-by-prettify">inl=
ine</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> a </sp=
an><span style=3D"color: #660;" class=3D"styled-by-prettify">=3D</span><spa=
n style=3D"color: #000;" class=3D"styled-by-prettify"> _a</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">;</span><span style=3D"color=
: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #800;" =
class=3D"styled-by-prettify">// 'a' is now by default an 'inline reference'=
 to '_a'</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><b=
r></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: #660;" class=3D"styled-by-prettify">;</span></div></code></div=
><div class=3D"subprettyprint" style=3D"background-color: rgb(250, 250, 250=
);"><span class=3D"styled-by-prettify" style=3D"font-family: monospace; col=
or: rgb(102, 102, 0);"><br><span style=3D"color: rgb(34, 34, 34); font-fami=
ly: Arial, Helvetica, sans-serif; background-color: rgb(255, 255, 255);">An=
d so now as '_a' is an inline reference all instances of 'a' will be replac=
ed with something similar to '</span></span><span style=3D"font-family: Ari=
al, Helvetica, sans-serif; background-color: white;">(const int)</span><spa=
n style=3D"font-family: Arial, Helvetica, sans-serif; background-color: rgb=
(255, 255, 255);">obj._a' and no run-time memory will be allocated.<br><br>=
As 'inline' will fully replace 'template''s we should talk about 'inline' f=
unctions and classes specializations. Every function which parameters and r=
eturn value types depends on other inline arguments can be</span><span styl=
e=3D"background-color: rgb(255, 255, 255);">&nbsp;specialize in another fun=
ction. Examples:<br><br></span></div><div class=3D"subprettyprint" style=3D=
"background-color: rgb(250, 250, 250);"><div class=3D"prettyprint" style=3D=
"border: 1px solid rgb(187, 187, 187); word-wrap: break-word; background-co=
lor: rgb(250, 250, 250);"><code class=3D"prettyprint"><div class=3D"subpret=
typrint"><span style=3D"color: #000;" class=3D"styled-by-prettify">func_add=
</span><span style=3D"color: #660;" class=3D"styled-by-prettify">(</span><s=
pan style=3D"color: #008;" class=3D"styled-by-prettify">inline</span><span =
style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"=
color: #008;" class=3D"styled-by-prettify">typename</span><span style=3D"co=
lor: #000;" class=3D"styled-by-prettify"> T</span><span style=3D"color: #66=
0;" class=3D"styled-by-prettify">,</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> T a</span><span style=3D"color: #660;" class=3D"st=
yled-by-prettify">,</span><span style=3D"color: #000;" class=3D"styled-by-p=
rettify"> T b</span><span style=3D"color: #660;" class=3D"styled-by-prettif=
y">)</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </spa=
n><span style=3D"color: #660;" class=3D"styled-by-prettify">-&gt;</span><sp=
an style=3D"color: #000;" class=3D"styled-by-prettify"> T<br></span><span s=
tyle=3D"color: #660;" class=3D"styled-by-prettify">{</span><span style=3D"c=
olor: #000;" class=3D"styled-by-prettify"><br></span><span style=3D"color: =
#660;" class=3D"styled-by-prettify">}</span><span style=3D"color: #000;" cl=
ass=3D"styled-by-prettify"> </span><span style=3D"color: #800;" class=3D"st=
yled-by-prettify">//'func_add' general inline function</span><span style=3D=
"color: #000;" class=3D"styled-by-prettify"><br><br>func_add</span><span st=
yle=3D"color: #660;" class=3D"styled-by-prettify">(</span><span style=3D"co=
lor: #008;" class=3D"styled-by-prettify">inline</span><span style=3D"color:=
 #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #008;" c=
lass=3D"styled-by-prettify">typename</span><span style=3D"color: #000;" cla=
ss=3D"styled-by-prettify"> T </span><span style=3D"color: #660;" class=3D"s=
tyled-by-prettify">=3D=3D</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">,=
</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> T a</span=
><span style=3D"color: #660;" class=3D"styled-by-prettify">,</span><span st=
yle=3D"color: #000;" class=3D"styled-by-prettify"> T b</span><span style=3D=
"color: #660;" class=3D"styled-by-prettify">)</span><span style=3D"color: #=
000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #660;" cla=
ss=3D"styled-by-prettify">-&gt;</span><span style=3D"color: #000;" class=3D=
"styled-by-prettify"> T<br></span><span style=3D"color: #660;" class=3D"sty=
led-by-prettify">{</span><span style=3D"color: #000;" class=3D"styled-by-pr=
ettify"><br><br></span><span style=3D"color: #660;" class=3D"styled-by-pret=
tify">}</span><span style=3D"color: #800;" class=3D"styled-by-prettify">//'=
func_add' specialization for int's - it doesn't have inline arguments or re=
turn-value so it's not implicitly converted into inline</span></div></code>=
</div><div class=3D"subprettyprint" style=3D"font-family: monospace;"><span=
 class=3D"styled-by-prettify" style=3D"color: rgb(136, 0, 0);"><br></span><=
/div></div><div class=3D"subprettyprint" style=3D"background-color: rgb(250=
, 250, 250);"><span style=3D"background-color: rgb(255, 255, 255);"><br></s=
pan></div><div class=3D"subprettyprint" style=3D"background-color: rgb(250,=
 250, 250);"><span class=3D"styled-by-prettify"><font color=3D"#000000"><fo=
nt face=3D"monospace">Note the syntax - function&nbsp;specialization of&nbs=
p;argument will be done by using the equal sign '=3D=3D'</font></font></spa=
n></div><div class=3D"subprettyprint" style=3D"background-color: rgb(250, 2=
50, 250);"><span style=3D"background-color: rgb(255, 255, 255);"><br></span=
></div><div class=3D"subprettyprint" style=3D"background-color: rgb(250, 25=
0, 250);"><span style=3D"background-color: rgb(255, 255, 255);">And several=
 example instances of '</span><span style=3D"color: rgb(0, 0, 0); font-fami=
ly: monospace;">func_add</span><span style=3D"background-color: rgb(255, 25=
5, 255);">':<br><br></span></div><div class=3D"prettyprint" style=3D"border=
: 1px solid rgb(187, 187, 187); word-wrap: break-word; background-color: rg=
b(250, 250, 250);"><code class=3D"prettyprint"><div class=3D"subprettyprint=
"><span style=3D"color: #000;" class=3D"styled-by-prettify">func_add</span>=
<span style=3D"color: #660;" class=3D"styled-by-prettify">(</span><span sty=
le=3D"color: #008;" class=3D"styled-by-prettify">double</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">,</span><span style=3D"color=
: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #066;" =
class=3D"styled-by-prettify">3.14</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: #066;" class=3D"styled-by-pret=
tify">2</span><span style=3D"color: #660;" class=3D"styled-by-prettify">);<=
/span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><sp=
an style=3D"color: #800;" class=3D"styled-by-prettify">//will instance inli=
ne function</span><span style=3D"color: #000;" class=3D"styled-by-prettify"=
><br><br>func_add</span><span style=3D"color: #660;" class=3D"styled-by-pre=
ttify">(</span><span style=3D"color: #008;" class=3D"styled-by-prettify">in=
t</span><span style=3D"color: #660;" class=3D"styled-by-prettify">,</span><=
span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span styl=
e=3D"color: #066;" class=3D"styled-by-prettify">3</span><span style=3D"colo=
r: #660;" class=3D"styled-by-prettify">,</span><span style=3D"color: #000;"=
 class=3D"styled-by-prettify"> </span><span style=3D"color: #066;" class=3D=
"styled-by-prettify">2</span><span style=3D"color: #660;" class=3D"styled-b=
y-prettify">);</span><span style=3D"color: #000;" class=3D"styled-by-pretti=
fy"> </span><span style=3D"color: #800;" class=3D"styled-by-prettify">//wil=
l instance the specialized 'int' function (note that the '=3D=3D' is differ=
ent than the '=3D' and we can not left the first argument position with no =
value)</span></div></code></div><div class=3D"subprettyprint" style=3D"back=
ground-color: rgb(250, 250, 250);"><span style=3D"background-color: rgb(255=
, 255, 255);"><br></span></div><div class=3D"subprettyprint" style=3D"backg=
round-color: rgb(250, 250, 250);"><span style=3D"background-color: rgb(255,=
 255, 255);"><br></span></div><div class=3D"subprettyprint" style=3D"backgr=
ound-color: rgb(250, 250, 250);"><span style=3D"background-color: rgb(255, =
255, 255);">And the word is given to 'class' specializations. A class will =
be specialized after it's 'inline' constructor ends execution. Object being=
 constructed using inline constructor, if when executed an&nbsp;specializat=
ion of the class is found it's constructor will be instanced too.&nbsp;Spec=
ialization of inline class members will be done using the 'equal' sign as t=
he arguments. Example:<br><br></span></div><div class=3D"subprettyprint" st=
yle=3D"background-color: rgb(250, 250, 250);"><div class=3D"prettyprint" st=
yle=3D"border: 1px solid rgb(187, 187, 187); word-wrap: break-word; backgro=
und-color: rgb(250, 250, 250);"><code class=3D"prettyprint"><div class=3D"s=
ubprettyprint"><span style=3D"color: #008;" class=3D"styled-by-prettify">cl=
ass</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> A </sp=
an><span style=3D"color: #800;" class=3D"styled-by-prettify">//general clas=
s</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br></spa=
n><span style=3D"color: #660;" class=3D"styled-by-prettify">{</span><span s=
tyle=3D"color: #000;" class=3D"styled-by-prettify"><br>&nbsp; &nbsp; T</spa=
n><span style=3D"color: #660;" class=3D"styled-by-prettify">(</span><span s=
tyle=3D"color: #008;" class=3D"styled-by-prettify">inline</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color=
: #008;" class=3D"styled-by-prettify">typename</span><span style=3D"color: =
#000;" class=3D"styled-by-prettify"> arg</span><span style=3D"color: #660;"=
 class=3D"styled-by-prettify">)</span><span style=3D"color: #000;" class=3D=
"styled-by-prettify"> </span><span style=3D"color: #660;" class=3D"styled-b=
y-prettify">:</span><span style=3D"color: #000;" class=3D"styled-by-prettif=
y"> T</span><span style=3D"color: #660;" class=3D"styled-by-prettify">(</sp=
an><span style=3D"color: #000;" class=3D"styled-by-prettify">arg</span><spa=
n style=3D"color: #660;" class=3D"styled-by-prettify">)</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color=
: #660;" class=3D"styled-by-prettify">{}</span><span style=3D"color: #000;"=
 class=3D"styled-by-prettify"><br><br>&nbsp; &nbsp; </span><span style=3D"c=
olor: #008;" class=3D"styled-by-prettify">inline</span><span style=3D"color=
: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #008;" =
class=3D"styled-by-prettify">typename</span><span style=3D"color: #000;" cl=
ass=3D"styled-by-prettify"> T</span><span style=3D"color: #660;" class=3D"s=
tyled-by-prettify">;</span><span style=3D"color: #000;" class=3D"styled-by-=
prettify"><br><br>&nbsp; &nbsp; T data</span><span style=3D"color: #660;" c=
lass=3D"styled-by-prettify">;</span><span style=3D"color: #000;" class=3D"s=
tyled-by-prettify"><br></span><span style=3D"color: #660;" class=3D"styled-=
by-prettify">}</span><span style=3D"color: #000;" class=3D"styled-by-pretti=
fy"> </span><span style=3D"color: #660;" class=3D"styled-by-prettify">;</sp=
an><span style=3D"color: #000;" class=3D"styled-by-prettify"><br><br><br></=
span><span style=3D"color: #008;" class=3D"styled-by-prettify">class</span>=
<span style=3D"color: #000;" class=3D"styled-by-prettify"> A </span><span s=
tyle=3D"color: #800;" class=3D"styled-by-prettify">//specialized class for =
int's</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br><=
/span><span style=3D"color: #660;" class=3D"styled-by-prettify">{</span><sp=
an style=3D"color: #000;" class=3D"styled-by-prettify"><br>&nbsp; &nbsp; T<=
/span><span style=3D"color: #660;" class=3D"styled-by-prettify">(</span><sp=
an style=3D"color: #008;" class=3D"styled-by-prettify">int</span><span styl=
e=3D"color: #000;" class=3D"styled-by-prettify"> arg</span><span style=3D"c=
olor: #660;" class=3D"styled-by-prettify">)</span><span style=3D"color: #00=
0;" class=3D"styled-by-prettify"> </span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">:</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify"> data</span><span style=3D"color: #660;" class=3D"styled-by-=
prettify">(</span><span style=3D"color: #000;" class=3D"styled-by-prettify"=
>arg</span><span style=3D"color: #660;" class=3D"styled-by-prettify">)</spa=
n><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span s=
tyle=3D"color: #660;" class=3D"styled-by-prettify">{</span><span style=3D"c=
olor: #000;" class=3D"styled-by-prettify"> cout </span><span style=3D"color=
: #660;" class=3D"styled-by-prettify">&lt;&lt;</span><span style=3D"color: =
#000;" class=3D"styled-by-prettify"> data </span><span style=3D"color: #660=
;" class=3D"styled-by-prettify">&lt;&lt;</span><span style=3D"color: #000;"=
 class=3D"styled-by-prettify"> endl</span><span style=3D"color: #660;" clas=
s=3D"styled-by-prettify">;</span><span style=3D"color: #000;" class=3D"styl=
ed-by-prettify"> </span><span style=3D"color: #660;" class=3D"styled-by-pre=
ttify">}</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><b=
r><br>&nbsp; &nbsp; </span><span style=3D"color: #008;" class=3D"styled-by-=
prettify">inline</span><span style=3D"color: #000;" class=3D"styled-by-pret=
tify"> </span><span style=3D"color: #008;" class=3D"styled-by-prettify">typ=
ename</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> T </=
span><span style=3D"color: #660;" class=3D"styled-by-prettify">=3D=3D</span=
><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span st=
yle=3D"color: #008;" class=3D"styled-by-prettify">int</span><span style=3D"=
color: #660;" class=3D"styled-by-prettify">;</span><span style=3D"color: #0=
00;" class=3D"styled-by-prettify"><br><br>&nbsp; &nbsp; T data</span><span =
style=3D"color: #660;" class=3D"styled-by-prettify">;</span><span style=3D"=
color: #000;" class=3D"styled-by-prettify"><br></span><span style=3D"color:=
 #660;" class=3D"styled-by-prettify">}</span><span style=3D"color: #000;" c=
lass=3D"styled-by-prettify"> </span><span style=3D"color: #660;" class=3D"s=
tyled-by-prettify">;</span></div></code></div><span class=3D"styled-by-pret=
tify" style=3D"font-family: monospace; color: rgb(102, 102, 0);"><br></span=
><span style=3D"background-color: rgb(255, 255, 255);"><br></span></div><di=
v class=3D"subprettyprint" style=3D"background-color: rgb(250, 250, 250);">=
<div class=3D"subprettyprint"><br><span style=3D"background-color: rgb(255,=
 255, 255);">And if we instance an object with some int like this for examp=
le:<br><br><br></span></div><div class=3D"subprettyprint"><span style=3D"ba=
ckground-color: rgb(255, 255, 255);"><div class=3D"prettyprint" style=3D"bo=
rder: 1px solid rgb(187, 187, 187); word-wrap: break-word; background-color=
: rgb(250, 250, 250);"><code class=3D"prettyprint"><div class=3D"subprettyp=
rint"><span style=3D"color: #000;" class=3D"styled-by-prettify">A obj</span=
><span style=3D"color: #660;" class=3D"styled-by-prettify">(</span><span st=
yle=3D"color: #066;" class=3D"styled-by-prettify">9</span><span style=3D"co=
lor: #660;" class=3D"styled-by-prettify">);</span></div></code></div><br></=
span></div><div class=3D"subprettyprint"><span style=3D"background-color: r=
gb(255, 255, 255);">This will happen - '</span><span class=3D"styled-by-pre=
ttify" style=3D"font-family: monospace; color: rgb(0, 0, 0);">T</span><span=
 class=3D"styled-by-prettify" style=3D"font-family: monospace; color: rgb(1=
02, 102, 0);">(</span><span class=3D"styled-by-prettify" style=3D"font-fami=
ly: monospace; color: rgb(0, 0, 136);">inline</span><span class=3D"styled-b=
y-prettify" style=3D"font-family: monospace; color: rgb(0, 0, 0);">&nbsp;</=
span><span class=3D"styled-by-prettify" style=3D"font-family: monospace; co=
lor: rgb(0, 0, 136);">typename</span><span class=3D"styled-by-prettify" sty=
le=3D"font-family: monospace; color: rgb(0, 0, 0);">&nbsp;arg</span><span c=
lass=3D"styled-by-prettify" style=3D"font-family: monospace; color: rgb(102=
, 102, 0);">)</span><span style=3D"background-color: rgb(255, 255, 255);">'=
 will be instanced, creating an 'class A' specialization with 'int', compil=
er will search if there exist and if so it'll start using it's&nbsp;functio=
nality and thus call '</span><span class=3D"styled-by-prettify" style=3D"fo=
nt-family: monospace; color: rgb(0, 0, 0);">T</span><span class=3D"styled-b=
y-prettify" style=3D"font-family: monospace; color: rgb(102, 102, 0);">(</s=
pan><span class=3D"styled-by-prettify" style=3D"font-family: monospace; col=
or: rgb(0, 0, 136);">int</span><span class=3D"styled-by-prettify" style=3D"=
font-family: monospace; color: rgb(0, 0, 0);">&nbsp;arg</span><span class=
=3D"styled-by-prettify" style=3D"font-family: monospace; color: rgb(102, 10=
2, 0);">)</span><span style=3D"background-color: rgb(255, 255, 255);">'</sp=
an><span style=3D"background-color: rgb(255, 255, 255);">&nbsp; and 'cout' =
9,</span></div><div class=3D"subprettyprint"><span style=3D"background-colo=
r: rgb(255, 255, 255);"><br></span></div><div class=3D"subprettyprint"><spa=
n style=3D"background-color: rgb(255, 255, 255);">Now some of you will ask =
- so every specialization will have the same type. No that's not true. In t=
he above example class 'A' is from type '</span>decltype(A(int{}))' but als=
o from type 'A', so if there is a function using it, they could either be g=
eneral for all 'A''s or only for the 'A''s with member 'T' of type 'int' li=
ke this:<br><br><div class=3D"prettyprint" style=3D"border: 1px solid rgb(1=
87, 187, 187); word-wrap: break-word; background-color: rgb(250, 250, 250);=
"><code class=3D"prettyprint"><div class=3D"subprettyprint"><span style=3D"=
color: #008;" class=3D"styled-by-prettify">void</span><span style=3D"color:=
 #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #606;" c=
lass=3D"styled-by-prettify">Func</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">(</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify">A obj</span><span style=3D"color: #660;" class=3D"styled-by-=
prettify">);</span><span style=3D"color: #000;" class=3D"styled-by-prettify=
"> </span><span style=3D"color: #800;" class=3D"styled-by-prettify">//gener=
al function for objects of type 'A' thus inline</span></div></code></div><b=
r></div></div><div class=3D"subprettyprint" style=3D"background-color: rgb(=
250, 250, 250);"><div class=3D"prettyprint" style=3D"border: 1px solid rgb(=
187, 187, 187); word-wrap: break-word; background-color: rgb(250, 250, 250)=
;"><code class=3D"prettyprint"><div class=3D"subprettyprint"><span style=3D=
"color: #008;" class=3D"styled-by-prettify">void</span><span style=3D"color=
: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #606;" =
class=3D"styled-by-prettify">Func</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">(</span><span style=3D"color: #008;" class=3D"style=
d-by-prettify">decltype</span><span style=3D"color: #660;" class=3D"styled-=
by-prettify">(</span><span style=3D"color: #000;" class=3D"styled-by-pretti=
fy">A</span><span style=3D"color: #660;" class=3D"styled-by-prettify">(</sp=
an><span style=3D"color: #008;" class=3D"styled-by-prettify">int</span><spa=
n style=3D"color: #660;" class=3D"styled-by-prettify">{}))</span><span styl=
e=3D"color: #000;" class=3D"styled-by-prettify"> obj</span><span style=3D"c=
olor: #660;" class=3D"styled-by-prettify">);</span><span style=3D"color: #0=
00;" class=3D"styled-by-prettify"> </span><span style=3D"color: #800;" clas=
s=3D"styled-by-prettify">//function of objects with specialized 'A' type wh=
ich left no inline members so function is not inline</span></div></code></d=
iv><br>The same applies for functions. Examples of function '<span style=3D=
"color: rgb(0, 0, 0); font-family: monospace;">func_add</span>':</div><div =
class=3D"subprettyprint" style=3D"background-color: rgb(250, 250, 250);"><b=
r></div><div class=3D"subprettyprint" style=3D"background-color: rgb(250, 2=
50, 250);"><div class=3D"subprettyprint"><div class=3D"prettyprint" style=
=3D"border: 1px solid rgb(187, 187, 187); word-wrap: break-word; background=
-color: rgb(250, 250, 250);"><code class=3D"prettyprint"><div class=3D"subp=
rettyprint"><span style=3D"color: #008;" class=3D"styled-by-prettify">void<=
/span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><sp=
an style=3D"color: #606;" class=3D"styled-by-prettify">Func</span><span sty=
le=3D"color: #660;" class=3D"styled-by-prettify">(</span><span style=3D"col=
or: #008;" class=3D"styled-by-prettify">decltype</span><span style=3D"color=
: #660;" class=3D"styled-by-prettify">(</span><span style=3D"color: #000;" =
class=3D"styled-by-prettify">func_add</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: #660;" class=3D"styled-by-p=
rettify">&amp;</span><span style=3D"color: #000;" class=3D"styled-by-pretti=
fy">obj</span><span style=3D"color: #660;" class=3D"styled-by-prettify">);<=
/span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><sp=
an style=3D"color: #800;" class=3D"styled-by-prettify">//general function w=
ith argument of type 'auto (&amp;)(inline typename T, T a, T b) -&gt; T', a=
s include inline members function implicit inline</span><span style=3D"colo=
r: #000;" class=3D"styled-by-prettify"><br><br></span></div></code></div><d=
iv class=3D"subprettyprint"><br><span style=3D"color: rgb(136, 0, 0); font-=
family: Arial, Helvetica, sans-serif;"><br></span></div></div><div class=3D=
"subprettyprint"><div class=3D"prettyprint" style=3D"border: 1px solid rgb(=
187, 187, 187); word-wrap: break-word; background-color: rgb(250, 250, 250)=
;"><code class=3D"prettyprint"><div class=3D"subprettyprint"><span style=3D=
"color: #008;" class=3D"styled-by-prettify">void</span><span style=3D"color=
: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #606;" =
class=3D"styled-by-prettify">Func</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">(</span><span style=3D"color: #008;" class=3D"style=
d-by-prettify">decltype</span><span style=3D"color: #660;" class=3D"styled-=
by-prettify">(</span><span style=3D"color: #000;" class=3D"styled-by-pretti=
fy">func_add</span><span style=3D"color: #660;" class=3D"styled-by-prettify=
">(</span><span style=3D"color: #008;" class=3D"styled-by-prettify">int</sp=
an><span style=3D"color: #660;" class=3D"styled-by-prettify">,</span><span =
style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"=
color: #008;" class=3D"styled-by-prettify">int</span><span style=3D"color: =
#660;" class=3D"styled-by-prettify">(),</span><span style=3D"color: #000;" =
class=3D"styled-by-prettify"> </span><span style=3D"color: #008;" class=3D"=
styled-by-prettify">int</span><span style=3D"color: #660;" class=3D"styled-=
by-prettify">()))</span><span style=3D"color: #000;" class=3D"styled-by-pre=
ttify"> </span><span style=3D"color: #660;" class=3D"styled-by-prettify">&a=
mp;</span><span style=3D"color: #000;" class=3D"styled-by-prettify">obj</sp=
an><span style=3D"color: #660;" class=3D"styled-by-prettify">);</span><span=
 style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D=
"color: #800;" class=3D"styled-by-prettify">//function with argument of typ=
e &nbsp;'auto (&amp;)(inline typename T =3D=3D int, T a, T b) -&gt; T', no =
inline so function isn't implicit inline</span></div></code></div><span sty=
le=3D"color: rgb(136, 0, 0); font-family: Arial, Helvetica, sans-serif;"><b=
r></span><span style=3D"background-color: rgb(255, 255, 255);">I believe th=
is wasn't the clearest wrote of my life but I also believe you got the poin=
t and the benefits of including this syntax.</span><span style=3D"color: rg=
b(136, 0, 0); font-family: Arial, Helvetica, sans-serif;"><br></span></div>=
</div></div></div></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_271_1048615353.1418737201599--
------=_Part_270_847709593.1418737201599--

.
