220 6861 <CAPBZbvy4Oo-AGc-Yh21x_ZF_ish8nAn79CqYRvrvCMLzGhd0fg@mail.gmail.com> article
Path: news.gmane.org!not-for-mail
From: "Billy O'Neal" <billy.oneal@gmail.com>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: Proposal: Class Frames to inject prefabricated
 features into classes
Date: Tue, 1 Oct 2013 13:53:12 -0700
Lines: 289
Approved: news@gmane.org
Message-ID: <CAPBZbvy4Oo-AGc-Yh21x_ZF_ish8nAn79CqYRvrvCMLzGhd0fg@mail.gmail.com>
References: <27c90f45-8ae6-44c1-8755-2b4cece26bcb@isocpp.org>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: plane.gmane.org
Mime-Version: 1.0
Content-Type: multipart/alternative; boundary=089e0129478479a30e04e7b426d3
X-Trace: ger.gmane.org 1380660830 32011 80.91.229.3 (1 Oct 2013 20:53:50 GMT)
X-Complaints-To: usenet@ger.gmane.org
NNTP-Posting-Date: Tue, 1 Oct 2013 20:53:50 +0000 (UTC)
To: std-proposals <std-proposals@isocpp.org>
Original-X-From: std-proposals+bncBDKLBLVE6ADBBYPMVSJAKGQESBOBBQY@isocpp.org Tue Oct 01 22:53:55 2013
Return-path: <std-proposals+bncBDKLBLVE6ADBBYPMVSJAKGQESBOBBQY@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+bncBDKLBLVE6ADBBYPMVSJAKGQESBOBBQY@isocpp.org>)
	id 1VR6x8-0007Xs-JR
	for gclcip-std-proposals@m.gmane.org; Tue, 01 Oct 2013 22:53:54 +0200
Original-Received: by mail-ie0-f199.google.com with SMTP id e14sf25236848iej.6
        for <gclcip-std-proposals@m.gmane.org>; Tue, 01 Oct 2013 13:53:53 -0700 (PDT)
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20130820;
        h=mime-version:in-reply-to:references:from:date:message-id:subject:to
         :x-original-sender:x-original-authentication-results:reply-to
         :precedence:mailing-list:list-id:list-post:list-help:list-archive
         :list-subscribe:list-unsubscribe:content-type;
        bh=wJ94CmHYhzrV5xTRXwZKqqF3roko+Vhzq6H/eTCTSgA=;
        b=CuoEwF6Oz+vz9jc/G9PJNJdxw7Q7PO2AGVnAn+l2yjosU9OY1yTe1HOsp89uNb9/lI
         pmjRqQB6GgPe8sKxPBI7Q/E1ezs3+7kgKSvGbYKEOnHwsM8ywLVtjQ/yn2vkp+ZWA8xE
         y2TCNCE4udWywcPDh8tictiGfGN2XKTSMvTsrmwLRpZYmY5GYwRlYaZ6dmwJuFYimwp6
         OC+XYvWT6zp+FngKnjlCASFhMRmxngbY36mfJmvOJ48Di9Cn6il94e2xIRV7O/6/EiAq
         ZNzb0+mT28ErbOEvTYYKMRnwFA4XY4eSjNl92ub1rFTdbJAvp+SysK4JGX3a76fD9poU
         mKdQ==
X-Received: by 10.42.191.81 with SMTP id dl17mr17283620icb.15.1380660833579;
        Tue, 01 Oct 2013 13:53:53 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.50.57.15 with SMTP id e15ls3024472igq.16.canary; Tue, 01 Oct
 2013 13:53:53 -0700 (PDT)
X-Received: by 10.60.115.164 with SMTP id jp4mr28486250oeb.19.1380660832927;
        Tue, 01 Oct 2013 13:53:52 -0700 (PDT)
Original-Received: from mail-ie0-x229.google.com (mail-ie0-x229.google.com [2607:f8b0:4001:c03::229])
        by mx.google.com with ESMTPS id i4si6255913oew.75.1969.12.31.16.00.00
        (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128);
        Tue, 01 Oct 2013 13:53:52 -0700 (PDT)
Received-SPF: pass (google.com: domain of billy.oneal@gmail.com designates 2607:f8b0:4001:c03::229 as permitted sender) client-ip=2607:f8b0:4001:c03::229;
Original-Received: by mail-ie0-f169.google.com with SMTP id tp5so15641586ieb.28
        for <std-proposals@isocpp.org>; Tue, 01 Oct 2013 13:53:52 -0700 (PDT)
X-Received: by 10.50.79.164 with SMTP id k4mr19687277igx.10.1380660832475;
 Tue, 01 Oct 2013 13:53:52 -0700 (PDT)
Original-Received: by 10.43.166.67 with HTTP; Tue, 1 Oct 2013 13:53:12 -0700 (PDT)
In-Reply-To: <27c90f45-8ae6-44c1-8755-2b4cece26bcb@isocpp.org>
X-Original-Sender: billy.oneal@gmail.com
X-Original-Authentication-Results: mx.google.com;       spf=pass (google.com:
 domain of billy.oneal@gmail.com designates 2607:f8b0:4001:c03::229 as
 permitted sender) smtp.mail=billy.oneal@gmail.com;       dkim=pass
 header.i=@gmail.com;       dmarc=pass (p=NONE dis=NONE) header.from=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: <http://groups.google.com/a/isocpp.org/group/std-proposals/subscribe>,
 <mailto:googlegroups-manage+399137483710+unsubscribe@googlegroups.com>
Xref: news.gmane.org gmane.comp.lang.c++.isocpp.proposals:6861
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/6861>

--089e0129478479a30e04e7b426d3
Content-Type: text/plain; charset=ISO-8859-1

How is this different than what you can already do with the existing:

template <typename T>
class MoveInjection
{
    T& operator=(T&&) { /*...*/ }
}

class Client : public MoveInjection<Client>
{

}


Billy O'Neal
https://github.com/BillyONeal/ <https://bitbucket.org/BillyONeal/>
http://stackoverflow.com/users/82320/billy-oneal
Malware Response Instructor - BleepingComputer.com


On Tue, Oct 1, 2013 at 11:33 AM, Mikhail Semenov <
mikhailsemenov1957@gmail.com> wrote:

> I propose to introduce class frames, which allow to inject features into
> classes, which in most cases are not available through inheritance. In
> addition, they
> don't require virtual functions, which makes them more efficient.
>
> *Part I*
> The frame provides features that are required for a class to be
> constructed; it and starts with a header:
> *class FrameName(class T)
> *or
> *struct FrameName(class T)*
>
>
> For example:
>
> *class MoveInjection(class T)
> {
> public:
>   T();        // to be defined in the class
>   T(const T&);// to be defined in the class
>   virtual ~T();// to be defined in the class
>   void swap(T&);// to be defined in the class
>   *
>
> *  T(T&& b):T() // is provided for the class
>   {
>      swap(b);
>   }*
>
> *  T& operator=(const T& b) // is provided for the class
>   {
>      T c(b);
>      swap(c);
>      return *this;
>   }*
>
> *  T& operator=(T&& b) // is provided for the class
>   {
>      swap(b);
>      return *this;
>   }
> };*
>
>
> The MoveInjection frame allows to create a class with a move constructor
> and assignment much easier: the programmer
> has to provide the definitions for T(), T(const& T&), ~T() and swap:
>
> *class A using MoveInjection
> {
> public:
>    A() {...}
>    A(const A& a) { ... }
>    virtual ~A() { ... }
>    void swap(T& a) { ... }
> };*
>
>
>
> The class frame may contain static objects:
>
> *class AddInjection(class T)
> {
>    static friend T operator+(class T& a, class T& b);
> };*
>
>
> *Part II*
>
> If the parameter inside a frame is not used, it can be dropped. In this
> case,
> it is possible to write:
>
> *class IntegralInjection()
> {
> public:
>     double integral(std::function<double(double)>, double a, double b);
> };*
>
> Such class frames can be used in a similar way:
> *class B using IntegralInjection
> {
> public:
>     double integral(std::function<double(double)>, double a, double b)
>     {
>       ...
>     }
>     ...
> };*
>
> But it is also possible to use such class frames in templates:
>
> *template Integrate<class A using IntegralInjection>
> ...*
> which means that this template requires the class to contain an integral
> function, which the given header.
>
> *Additional features of class frames*
>
> (1) It should be possible to use several frames to inject various features
> into a class.
>
> (2) A class frame itself can be defined in a template:
> *template<class A>*
> *class SpecialInjection(class B)*
> *{*
> *....*
> *};*
>
> **
>
>
>
>
>
> --
>
> ---
> 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/.
>

-- 

--- 
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/.

--089e0129478479a30e04e7b426d3
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div>How is this different than what you can already do wi=
th the existing:</div><div>=A0</div><div>template &lt;typename T&gt;</div><=
div>class MoveInjection</div><div>{</div><div>=A0=A0=A0 T&amp;=A0operator=
=3D(T&amp;&amp;) { /*...*/ }</div>

<div>}</div><div>=A0</div><div>class Client : public MoveInjection&lt;Clien=
t&gt;</div><div>{</div><div>=A0</div><div>}</div><div>=A0</div></div><div c=
lass=3D"gmail_extra"><br clear=3D"all"><div><div dir=3D"ltr"><div>Billy O&#=
39;Neal</div>

<div><a href=3D"https://bitbucket.org/BillyONeal/" target=3D"_blank">https:=
//github.com/BillyONeal/</a></div><div><a href=3D"http://stackoverflow.com/=
users/82320/billy-oneal" target=3D"_blank">http://stackoverflow.com/users/8=
2320/billy-oneal</a></div>

<div>Malware Response Instructor - BleepingComputer.com</div></div></div>
<br><br><div class=3D"gmail_quote">On Tue, Oct 1, 2013 at 11:33 AM, Mikhail=
 Semenov <span dir=3D"ltr">&lt;<a href=3D"mailto:mikhailsemenov1957@gmail.c=
om" target=3D"_blank">mikhailsemenov1957@gmail.com</a>&gt;</span> wrote:<br=
><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1=
px #ccc solid;padding-left:1ex">

<div dir=3D"ltr"><div>I propose to introduce class frames, which allow to i=
nject features into classes, which in most cases are not available through =
inheritance. In addition, they</div><div>don&#39;t require virtual function=
s, which makes them more efficient.</div>

<div>=A0</div><div><strong><u>Part I</u></strong><font face=3D"trebuchet ms=
,sans-serif" style=3D"background-color:rgb(153,0,255)"><br></font></div><di=
v>The frame provides features that are required for a class to be construct=
ed; it and starts with a header:<br>

<strong>class FrameName(class T)<br></strong>or<br><strong>struct FrameName=
(class T)</strong></div><p><br>For example:</p><p><strong>class MoveInjecti=
on(class T)<br>{<br>public:<br>=A0 T();=A0=A0=A0=A0=A0=A0=A0 // to be defin=
ed in the class<br>

=A0 T(const T&amp;);// to be defined in the class<br>=A0 virtual ~T();// to=
 be defined in the class<br>=A0 void swap(T&amp;);// to be defined in the c=
lass<br>=A0 </strong></p><p><strong>=A0 T(T&amp;&amp; b):T() // is provided=
 for the class<br>

=A0 {<br>=A0=A0=A0=A0 swap(b);<br>=A0 }</strong></p><p><strong>=A0 T&amp; o=
perator=3D(const T&amp; b) // is provided for the class<br>=A0 {<br>=A0=A0=
=A0=A0 T c(b);<br>=A0=A0=A0=A0 swap(c);<br>=A0=A0=A0=A0 return *this;<br>=
=A0 }</strong></p><p><strong>=A0 T&amp; operator=3D(T&amp;&amp; b) // is pr=
ovided for the class<br>

=A0 {<br>=A0=A0=A0=A0 swap(b);<br>=A0=A0=A0=A0 return *this;<br>=A0 }<br>};=
</strong></p><p><br>The MoveInjection frame allows to create a class with a=
 move constructor and assignment much easier: the programmer<br>has to prov=
ide the definitions for T(), T(const&amp; T&amp;), ~T() and swap:</p>

<p><strong>class A using MoveInjection<br>{<br>public:<br>=A0=A0 A() {...}<=
br>=A0=A0 A(const A&amp; a) { ... }<br>=A0=A0 virtual ~A() { ... }<br>=A0=
=A0 void swap(T&amp; a) { ... }<br>};</strong></p><p>=A0</p><p>The class fr=
ame may contain static objects:</p>

<p><strong>class AddInjection(class T)<br>{<br>=A0=A0 static friend T opera=
tor+(class T&amp; a, class T&amp; b);<br>};</strong></p><p><br><strong><u>P=
art II</u></strong></p><p>If the parameter inside a frame is not used, it c=
an be dropped. In this case,<br>

it is possible to write:</p><p><strong>class IntegralInjection()<br>{<br>pu=
blic:<br>=A0=A0=A0 double integral(std::function&lt;double(double)&gt;, dou=
ble a, double b);<br>};</strong></p><p>Such class frames can be used in a s=
imilar way:<br>

<strong>class B using IntegralInjection<br>{<br>public:<br>=A0=A0=A0 double=
 integral(std::function&lt;double(double)&gt;, double a, double b)<br>=A0=
=A0=A0 {<br>=A0=A0=A0=A0=A0 ...<br>=A0=A0=A0 }<br>=A0=A0=A0 ...<br>};</stro=
ng></p><p>But it is also possible to use such class frames in templates:</p=
>

<p><strong>template Integrate&lt;class A using IntegralInjection&gt;<br>...=
</strong></p><div>which means that this template requires the class to cont=
ain an integral function, which the given header.</div><div>=A0</div><div>

<strong><u>Additional features of class frames</u></strong></div><div>=A0</=
div><div>(1) It=A0should be=A0possible to use several frames to inject vari=
ous features into a class. </div><div>=A0</div><div>(2) A class frame itsel=
f can be defined in a template:</div>

<div><strong>template&lt;class A&gt;</strong></div><div><strong>class Speci=
alInjection(class B)</strong></div><div><strong>{</strong></div><div><stron=
g>....</strong></div><div><strong>};</strong></div><span class=3D"HOEnZb"><=
font color=3D"#888888"><p>

<strong></strong>=A0</p><p>=A0</p><p>=A0</p></font></span></div><span class=
=3D"HOEnZb"><font color=3D"#888888">

<p></p>

-- <br>
=A0<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%2Bunsubscribe@isocpp.org" target=3D=
"_blank">std-proposals+unsubscribe@isocpp.org</a>.<br>
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org" target=3D"_blank">std-proposals@isocpp.org</a>.<br>
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/" target=3D"_blank">http://groups.google.com/a/isocpp.org/gro=
up/std-proposals/</a>.<br>
</font></span></blockquote></div><br></div>

<p></p>

-- <br />
&nbsp;<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 std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<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 />

--089e0129478479a30e04e7b426d3--

.
