220 5911 <CAGg_6+Mzv62kOm58vtn5yU6Wv2HeohLcg-hmd7Cjiw3D2KJb1Q@mail.gmail.com> article
Path: news.gmane.org!not-for-mail
From: Nevin Liber <nevin@eviloverlord.com>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: Proposal: Mixins for C++
Date: Tue, 27 Aug 2013 19:58:27 -0500
Lines: 152
Approved: news@gmane.org
Message-ID: <CAGg_6+Mzv62kOm58vtn5yU6Wv2HeohLcg-hmd7Cjiw3D2KJb1Q@mail.gmail.com>
References: <787081f7-fb40-4507-907d-259318ef2000@isocpp.org>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: plane.gmane.org
Mime-Version: 1.0
Content-Type: multipart/alternative; boundary=001a11c35e1823036604e4f77fca
X-Trace: ger.gmane.org 1377651553 19470 80.91.229.3 (28 Aug 2013 00:59:13 GMT)
X-Complaints-To: usenet@ger.gmane.org
NNTP-Posting-Date: Wed, 28 Aug 2013 00:59:13 +0000 (UTC)
To: "std-proposals@isocpp.org" <std-proposals@isocpp.org>
Original-X-From: std-proposals+bncBCE35H5S6IDBBXMW6WIAKGQEWVZVKJQ@isocpp.org Wed Aug 28 02:59:16 2013
Return-path: <std-proposals+bncBCE35H5S6IDBBXMW6WIAKGQEWVZVKJQ@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-vb0-f72.google.com ([209.85.212.72])
	by plane.gmane.org with esmtp (Exim 4.69)
	(envelope-from <std-proposals+bncBCE35H5S6IDBBXMW6WIAKGQEWVZVKJQ@isocpp.org>)
	id 1VEU6I-0007l5-RU
	for gclcip-std-proposals@m.gmane.org; Wed, 28 Aug 2013 02:59:11 +0200
Original-Received: by mail-vb0-f72.google.com with SMTP id f12sf6015454vbg.3
        for <gclcip-std-proposals@m.gmane.org>; Tue, 27 Aug 2013 17:59:09 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20120113;
        h=mime-version:sender: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=aOiuiVMe7CbC2nrJwQ1wwQeBlWnnbdUDJiEziq8NmJU=;
        b=c+/GVO87aozDBqHhNh5vG91GwkQbL5m9MPBrCPWnj3DCOdb8jVKW/Xv2SomuX785Ko
         BMTquoUJwLz61cdL2/t2zyKhl+g/qV5qGjhUtGqbDFXE9FJOhxH24mV4l5l0xl0uDLJm
         JhingVXkaHOXzGaKKlI4Ixkmy1jklwITy32bb/eKH7IuqW/gFSBHCvhKf6HPcsXqT/gv
         q8DjB8UjNToJ11rRPgvliH7FfCWMhXmyNktC77XfG8F+VqMNeo8wxuTwWQ+OJ2BuhnAm
         xUo7we21BI5+cfpByfOuS5qpS7u7vFY4oC6WJRRLFNSAz0m00eVvQIuafkU2M9B2f8FF
         CNRw==
X-Received: by 10.236.116.135 with SMTP id g7mr2189445yhh.53.1377651549689;
        Tue, 27 Aug 2013 17:59:09 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.49.85.134 with SMTP id h6ls149426qez.10.gmail; Tue, 27 Aug
 2013 17:59:09 -0700 (PDT)
X-Received: by 10.49.63.3 with SMTP id c3mr27100511qes.2.1377651549087;
        Tue, 27 Aug 2013 17:59:09 -0700 (PDT)
Original-Received: from mail-qc0-x229.google.com (mail-qc0-x229.google.com [2607:f8b0:400d:c01::229])
        by mx.google.com with ESMTPS id q8si9026161qer.100.1969.12.31.16.00.00
        (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128);
        Tue, 27 Aug 2013 17:59:08 -0700 (PDT)
Received-SPF: pass (google.com: domain of nliber@gmail.com designates 2607:f8b0:400d:c01::229 as permitted sender) client-ip=2607:f8b0:400d:c01::229;
Original-Received: by mail-qc0-f169.google.com with SMTP id k8so1805766qcq.28
        for <std-proposals@isocpp.org>; Tue, 27 Aug 2013 17:59:08 -0700 (PDT)
X-Received: by 10.229.196.71 with SMTP id ef7mr4713064qcb.4.1377651547896;
 Tue, 27 Aug 2013 17:59:07 -0700 (PDT)
Original-Sender: nliber@gmail.com
Original-Received: by 10.49.3.41 with HTTP; Tue, 27 Aug 2013 17:58:27 -0700 (PDT)
In-Reply-To: <787081f7-fb40-4507-907d-259318ef2000@isocpp.org>
X-Original-Sender: nevin@eviloverlord.com
X-Original-Authentication-Results: mx.google.com;       spf=pass (google.com:
 domain of nliber@gmail.com designates 2607:f8b0:400d:c01::229 as permitted
 sender) smtp.mail=nliber@gmail.com;       dkim=pass header.i=@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:5911
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/5911>

--001a11c35e1823036604e4f77fca
Content-Type: text/plain; charset=ISO-8859-1

On 27 August 2013 16:14, Sebastian Redl <wasti.redl@gmx.net> wrote:

> === Mixins (Class Extension Blocks) for C++ ===
>

0.  I would get rid of the references to how things were written back in
the C++03 days.  This is for C++17; it should be solving the things we
can't (easily) write with C++14 and Concepts Lite.

1.  Change the syntax by making the implicit template argument explicit, as
in:

template<typename T>
mixin noncopyable
{ /*... */ };

This gives you a name for the type instantiated (instead of the weird
decltype(mixin)) and makes it obvious it is templated.  While it violates
DRY (Don't Repeat Yourself), instantiating it should also require
specifying T, as it is more uniform with the rest of the language.
 Example 1: Non-Copyable

> Here's a non-copyable mixin:
>
> mixin noncopyable {
>   noncopyable(const noncopyable&) = delete;
>   noncopyable& operator =(const noncopyable&) = delete;
> }
> class foo {
>   using mixin noncopyable;
> };
>
> Here, the compiler will fail to generate the copy functions for foo,
> because
> they would have to call the mixin's copy functions, which are deleted.
>

For each of the following can you tell me if they are intended to be (a)
copyable, (b) non-copyable or (c) non-compileable?

struct One {
    using mixin noncopyable;
};

struct Two {
    using mixin noncopyable;
    Two(Two const&) = default;
    Two& operator=(Two const&) = default;
};

struct Three {
    using mixin noncopyable;
    Three(Three const&) {}
    Three& operator=(Three const&) { return *this; }
};

Anyway, just my initial questions...
-- 
 Nevin ":-)" Liber  <mailto:nevin@eviloverlord.com>  (847) 691-1404

-- 

--- 
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/.

--001a11c35e1823036604e4f77fca
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div class=3D"gmail_extra">On 27 August 2013 16:14, Sebast=
ian Redl <span dir=3D"ltr">&lt;<a href=3D"mailto:wasti.redl@gmx.net" target=
=3D"_blank">wasti.redl@gmx.net</a>&gt;</span> wrote:<br></div><div class=3D=
"gmail_extra">

<div class=3D"gmail_quote"><blockquote class=3D"gmail_quote" style=3D"margi=
n-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0.8ex;border-left-=
width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;paddin=
g-left:1ex">

<div dir=3D"ltr">=3D=3D=3D Mixins (Class Extension Blocks) for C++ =3D=3D=
=3D<br></div></blockquote><div><br></div><div>0. =A0I would get rid of the =
references to how things were written back in the C++03 days. =A0This is fo=
r C++17; it should be solving the things we can&#39;t (easily) write with C=
++14 and Concepts Lite.</div>

<div><br></div><div>1. =A0Change the syntax by making the implicit template=
 argument explicit, as in:</div><div><br></div><div>template&lt;typename T&=
gt;</div><div>mixin noncopyable</div><div>{ /*... */=A0};</div><div><br></d=
iv>

<div>This gives you a name for the type instantiated (instead of the weird =
decltype(mixin)) and makes it obvious it is templated. =A0While it violates=
 DRY (Don&#39;t Repeat Yourself), instantiating it should also require spec=
ifying T, as it is more uniform with the rest of the language.</div>

<div>=A0Example 1: Non-Copyable</div><blockquote class=3D"gmail_quote" styl=
e=3D"margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0.8ex;bo=
rder-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:so=
lid;padding-left:1ex">

<div dir=3D"ltr">Here&#39;s a non-copyable mixin:<br><br><span style=3D"fon=
t-family:&#39;courier new&#39;,monospace">mixin noncopyable {<br>=A0 noncop=
yable(const noncopyable&amp;) =3D delete;<br>=A0 noncopyable&amp; operator =
=3D(const noncopyable&amp;) =3D delete;<br>

}<br>class foo {<br>=A0 using mixin noncopyable;<br>};<br></span><br>Here, =
the compiler will fail to generate the copy functions for foo, because<br>t=
hey would have to call the mixin&#39;s copy functions, which are deleted.</=
div>

</blockquote><div><br></div><div>For each of the following can you tell me =
if they are intended to be (a) copyable, (b) non-copyable or (c) non-compil=
eable?<br></div><div><br></div><div>struct One {</div><div>=A0 =A0 using mi=
xin noncopyable;</div>

<div>};</div><div><br></div><div>struct Two {</div><div>=A0 =A0 using mixin=
 noncopyable;</div><div>=A0 =A0 Two(Two const&amp;) =3D default;</div><div>=
=A0 =A0 Two&amp; operator=3D(Two const&amp;) =3D default;</div><div>};</div=
><div><br></div>

<div>struct Three {</div><div>=A0 =A0 using mixin noncopyable;</div><div>=
=A0 =A0 Three(Three const&amp;) {}</div><div>=A0 =A0 Three&amp; operator=3D=
(Three const&amp;) { return *this; }</div><div>};</div><div><br></div></div=
><div>Anyway, just my initial questions...</div>

-- <br>=A0Nevin &quot;:-)&quot; Liber=A0 &lt;mailto:<a href=3D"mailto:nevin=
@eviloverlord.com" target=3D"_blank">nevin@eviloverlord.com</a>&gt;=A0 (847=
) 691-1404
</div></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 />

--001a11c35e1823036604e4f77fca--

.
