220 32840 <d6138434-59ef-42d7-82d8-f2934c6f3bfb@isocpp.org> article
Path: news.gmane.org!.POSTED!not-for-mail
From: Mingxin Wang <wmx16835vv@163.com>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: The Proxies - A Language Feature Decoupling
 Implementations from Requirements of Polymorphism
Date: Wed, 21 Jun 2017 20:02:35 -0700 (PDT)
Lines: 124
Approved: news@gmane.org
Message-ID: <d6138434-59ef-42d7-82d8-f2934c6f3bfb@isocpp.org>
References: <8d79a013-fe0e-4fb6-8278-d438ae9b4c64@isocpp.org>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: blaine.gmane.org
Mime-Version: 1.0
Content-Type: multipart/mixed; 
	boundary="----=_Part_5523_222890770.1498100555430"
X-Trace: blaine.gmane.org 1498100556 27353 195.159.176.226 (22 Jun 2017 03:02:36 GMT)
X-Complaints-To: usenet@blaine.gmane.org
NNTP-Posting-Date: Thu, 22 Jun 2017 03:02:36 +0000 (UTC)
To: ISO C++ Standard - Future Proposals <std-proposals@isocpp.org>
Original-X-From: std-proposals+bncBDNMBNHJWIGBBTHGVTFAKGQE4OKPZ6A@isocpp.org Thu Jun 22 05:02:32 2017
Return-path: <std-proposals+bncBDNMBNHJWIGBBTHGVTFAKGQE4OKPZ6A@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-pf0-f197.google.com ([209.85.192.197])
	by blaine.gmane.org with esmtp (Exim 4.84_2)
	(envelope-from <std-proposals+bncBDNMBNHJWIGBBTHGVTFAKGQE4OKPZ6A@isocpp.org>)
	id 1dNsO8-0006mw-Ay
	for gclcip-std-proposals@m.gmane.org; Thu, 22 Jun 2017 05:02:32 +0200
Original-Received: by mail-pf0-f197.google.com with SMTP id s65sf3755728pfi.14
        for <gclcip-std-proposals@m.gmane.org>; Wed, 21 Jun 2017 20:02:37 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=isocpp-org.20150623.gappssmtp.com; s=20150623;
        h=date:from:to:message-id:in-reply-to:references:subject:mime-version
         :x-original-sender:reply-to:precedence:mailing-list:list-id
         :list-post:list-help:list-archive:list-subscribe:list-unsubscribe;
        bh=4zlsjiQ3U1VYkBTOX7DaZ9OLgPCtVIfZAgHoADlt/es=;
        b=nDlLpDA0jOisaBmYLng7p71NJga7CvnZx8wsy7iA5p97n4aLy+9qmkFbybbKnMBogy
         VxDVjf20l30ukMxTKcXGXCBs89MPhf6n3ZMzRXqrgYrXx8mfFqHPHvxPgxX2gSp+aJDp
         Fweh7Rf2fy6s1qyWxCRVvo0uYhEglg8Fd/ZSAVW/ulqlb23TlLPsH2fLlBD1SrcMGXfW
         E//ReyxxHcA7jLLAAv26XIqz5SjGHo3mZjjv7Dbq8TGWCsFtkvgmtNjPyLkTW9BX/2Fj
         /wpDf+SrEfKFjfwNCXom6G8P6PYJ4EbPJTVsXK59chRx2ApN7VCkgx/mZ2PexFgh6E3J
         BzVA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20161025;
        h=x-gm-message-state:date:from:to:message-id:in-reply-to:references
         :subject:mime-version:x-original-sender:reply-to:precedence
         :mailing-list:list-id:x-spam-checked-in-group:list-post:list-help
         :list-archive:list-subscribe:list-unsubscribe;
        bh=4zlsjiQ3U1VYkBTOX7DaZ9OLgPCtVIfZAgHoADlt/es=;
        b=bUulDsE3fUIMH+wZ8eKh8DdDr0TWKFKtscBfofBDB4QJEmO1lRjlzwNcn6KUGp4vtH
         0sKcelTS00rgOkICGika/99VlyUsQ1DC8IIodXJzBqJfD4ycZlN4UFyEgnm+3+EHqC8E
         0GiqZfG9Xf0nWSL9fqIdoLSaRFRkz00MOK+6yrffSUnSu6UaL2ibkNCp2UogJaQfEmwr
         bL801MnAoDWHJEhdWeZN48Ohz4t7COAhaGV367zAeSktctJL1m8Iq3de/sqXBugmVdyn
         coXmc1MEzzItNkf+aVAjsEJWA8tmyaWdtt+LVg1fSirgxxS6O0zgm9KPN/YjpAHXnTQI
         /uCw==
X-Gm-Message-State: AKS2vOwXaQSIMneMqB59vT9JEGwJou5ROH2eiRiY8q30WZiRltvl3toc
	xUClc7HaPERyhE4Q
X-Received: by 10.98.196.3 with SMTP id y3mr123688pff.23.1498100556917;
        Wed, 21 Jun 2017 20:02:36 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.157.23.40 with SMTP id i40ls640076ota.32.gmail; Wed, 21 Jun
 2017 20:02:36 -0700 (PDT)
X-Received: by 10.157.52.161 with SMTP id g30mr7233otc.17.1498100556010;
        Wed, 21 Jun 2017 20:02:36 -0700 (PDT)
In-Reply-To: <8d79a013-fe0e-4fb6-8278-d438ae9b4c64@isocpp.org>
X-Original-Sender: wmx16835vv@163.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: <https://groups.google.com/a/isocpp.org/group/std-proposals/post>, <mailto:std-proposals@isocpp.org>
List-Help: <https://support.google.com/a/isocpp.org/bin/topic.py?topic=25838>, <mailto:std-proposals+help@isocpp.org>
List-Archive: <https://groups.google.com/a/isocpp.org/group/std-proposals/>
List-Subscribe: <https://groups.google.com/a/isocpp.org/group/std-proposals/subscribe>,
 <mailto:std-proposals+subscribe@isocpp.org>
List-Unsubscribe: <mailto:googlegroups-manage+399137483710+unsubscribe@googlegroups.com>,
 <https://groups.google.com/a/isocpp.org/group/std-proposals/subscribe>
Xref: news.gmane.org gmane.comp.lang.c++.isocpp.proposals:32840
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/32840>

------=_Part_5523_222890770.1498100555430
Content-Type: multipart/alternative; 
	boundary="----=_Part_5524_809515705.1498100555430"

------=_Part_5524_809515705.1498100555430
Content-Type: text/plain; charset="UTF-8"

I designed another general wrapper type yesterday, which is intended for 
small and trivial types, as is shown below:

template <std::size_t SIZE>
class TrivialWrapper {
 public:
  /* Constructors */
  template <class T>
  TrivialWrapper(T&& data) requires
      !std::is_same<std::remove_cv_t<std::remove_reference_t<T>>, 
TrivialWrapper>::value &&
      std::is_trivial<std::remove_cv_t<std::remove_reference_t<T>>>::value 
&&
      (sizeof(std::remove_cv_t<std::remove_reference_t<T>>) <= SIZE) {
    memcpy(data_.get(), &data, 
sizeof(std::remove_cv_t<std::remove_reference_t<T>>));
  }
  TrivialWrapper() = default;
  TrivialWrapper(const TrivialWrapper&) = default;
  TrivialWrapper(TrivialWrapper&&) = default;

  TrivialWrapper& operator=(const TrivialWrapper& rhs) = default;
  TrivialWrapper& operator=(TrivialWrapper&&) = default;

  /* Meets the Wrapper requirements */
  void* get() {
    // The address of the wrapped object is calculated with a constant 
offset
    return data_.get();
  }

 private:
  MemoryBlock<SIZE> data_;
};


I am wondering if these design for wrappers (DeferredWrapper, DeepWrapper, 
SharedWrapper and TrivialWrapper) are adequate to be added to the standard 
(discard of naming).

I am looking forward to your comments and suggestions!

Thank you!

Mingxin Wang

-- 
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.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/d6138434-59ef-42d7-82d8-f2934c6f3bfb%40isocpp.org.

------=_Part_5524_809515705.1498100555430
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div>I designed another general wrapper type yesterday, wh=
ich is intended for small and trivial types, as is shown below:<br></div><d=
iv><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"subprettyprint"><font color=
=3D"#660066"><div class=3D"subprettyprint">template &lt;std::size_t SIZE&gt=
;</div><div class=3D"subprettyprint">class TrivialWrapper {</div><div class=
=3D"subprettyprint">=C2=A0public:</div><div class=3D"subprettyprint">=C2=A0=
 /* Constructors */</div><div class=3D"subprettyprint">=C2=A0 template &lt;=
class T&gt;</div><div class=3D"subprettyprint">=C2=A0 TrivialWrapper(T&amp;=
&amp; data) requires</div><div class=3D"subprettyprint">=C2=A0 =C2=A0 =C2=
=A0 !std::is_same&lt;std::remove_cv_t&lt;std::remove_reference_t&lt;T&gt;&g=
t;, TrivialWrapper&gt;::value &amp;&amp;</div><div class=3D"subprettyprint"=
>=C2=A0 =C2=A0 =C2=A0 std::is_trivial&lt;std::remove_cv_t&lt;std::remove_re=
ference_t&lt;T&gt;&gt;&gt;::value &amp;&amp;</div><div class=3D"subprettypr=
int">=C2=A0 =C2=A0 =C2=A0 (sizeof(std::remove_cv_t&lt;std::remove_reference=
_t&lt;T&gt;&gt;) &lt;=3D SIZE) {</div><div class=3D"subprettyprint">=C2=A0 =
=C2=A0 memcpy(data_.get(), &amp;data, sizeof(std::remove_cv_t&lt;std::remov=
e_reference_t&lt;T&gt;&gt;));</div><div class=3D"subprettyprint">=C2=A0 }</=
div><div class=3D"subprettyprint">=C2=A0 TrivialWrapper() =3D default;</div=
><div class=3D"subprettyprint">=C2=A0 TrivialWrapper(const TrivialWrapper&a=
mp;) =3D default;</div><div class=3D"subprettyprint">=C2=A0 TrivialWrapper(=
TrivialWrapper&amp;&amp;) =3D default;</div><div class=3D"subprettyprint"><=
br></div><div class=3D"subprettyprint">=C2=A0 TrivialWrapper&amp; operator=
=3D(const TrivialWrapper&amp; rhs) =3D default;</div><div class=3D"subprett=
yprint">=C2=A0 TrivialWrapper&amp; operator=3D(TrivialWrapper&amp;&amp;) =
=3D default;</div><div class=3D"subprettyprint"><br></div><div class=3D"sub=
prettyprint">=C2=A0 /* Meets the Wrapper requirements */</div><div class=3D=
"subprettyprint">=C2=A0 void* get() {</div><div class=3D"subprettyprint">=
=C2=A0 =C2=A0 // The address of the wrapped object is calculated with a con=
stant offset</div><div class=3D"subprettyprint">=C2=A0 =C2=A0 return data_.=
get();</div><div class=3D"subprettyprint">=C2=A0 }</div><div class=3D"subpr=
ettyprint"><br></div><div class=3D"subprettyprint">=C2=A0private:</div><div=
 class=3D"subprettyprint">=C2=A0 MemoryBlock&lt;SIZE&gt; data_;</div><div c=
lass=3D"subprettyprint">};</div></font></div></code></div><br><br></div><di=
v>I am wondering if these design for wrappers (DeferredWrapper, DeepWrapper=
, SharedWrapper and TrivialWrapper) are adequate to be added to the standar=
d (discard of naming).</div><div><br></div><div>I am looking forward to you=
r comments and suggestions!</div><div><br></div><div>Thank you!</div><div><=
br></div><div>Mingxin Wang</div></div>

<p></p>

-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/d6138434-59ef-42d7-82d8-f2934c6f3bfb%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/d6138434-59ef-42d7-82d8-f2934c6f3bfb=
%40isocpp.org</a>.<br />

------=_Part_5524_809515705.1498100555430--

------=_Part_5523_222890770.1498100555430--

.
