220 32842 <20170622082445.GA5007@noemi.bahnhof.se> article
Path: news.gmane.org!.POSTED!not-for-mail
From: Magnus Fromreide <magfr@lysator.liu.se>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: Re: The Proxies - A Language Feature Decoupling
 Implementations from Requirements of Polymorphism
Date: Thu, 22 Jun 2017 10:24:45 +0200
Lines: 65
Approved: news@gmane.org
Message-ID: <20170622082445.GA5007@noemi.bahnhof.se>
References: <8d79a013-fe0e-4fb6-8278-d438ae9b4c64@isocpp.org>
 <d6138434-59ef-42d7-82d8-f2934c6f3bfb@isocpp.org>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: blaine.gmane.org
Mime-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
X-Trace: blaine.gmane.org 1498119890 27297 195.159.176.226 (22 Jun 2017 08:24:50 GMT)
X-Complaints-To: usenet@blaine.gmane.org
NNTP-Posting-Date: Thu, 22 Jun 2017 08:24:50 +0000 (UTC)
User-Agent: Mutt/1.8.0 (2017-02-23)
To: std-proposals@isocpp.org
Original-X-From: std-proposals+bncBDELLREETMBRBUH5VXFAKGQEXPIBQ7Y@isocpp.org Thu Jun 22 10:24:45 2017
Return-path: <std-proposals+bncBDELLREETMBRBUH5VXFAKGQEXPIBQ7Y@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-lf0-f71.google.com ([209.85.215.71])
	by blaine.gmane.org with esmtp (Exim 4.84_2)
	(envelope-from <std-proposals+bncBDELLREETMBRBUH5VXFAKGQEXPIBQ7Y@isocpp.org>)
	id 1dNxPx-0006m3-JR
	for gclcip-std-proposals@m.gmane.org; Thu, 22 Jun 2017 10:24:45 +0200
Original-Received: by mail-lf0-f71.google.com with SMTP id u62sf2159967lfg.6
        for <gclcip-std-proposals@m.gmane.org>; Thu, 22 Jun 2017 01:24:51 -0700 (PDT)
ARC-Seal: i=2; a=rsa-sha256; t=1498119890; cv=pass;
        d=google.com; s=arc-20160816;
        b=eFWtBuxJ6Ql3Azae9DEaVE36OKMyKRtNcnLTsp+Tyh4EFGX14R7qd4+EvcWGr/6rKb
         oQqlkOyxxYAfTSDM3eudjLF7co370HZQkJLvRJYVfPuzBp5o4x5z7kmC+ALw13VVwj6W
         f4SJdZaTjBwfpLb4bk6UFRqv6nJqKUm66ExuSIJ0tirThVmQ0Dap/72Yxo7MBmk6I95q
         6XkOLXsuoeHa0F1GAVWiz4cL2/C9xlDkxlZ0hiLxKVwmfXosqIq23G6T287Dg/L6QMK+
         FU3qg1qBH0f2v7R9AuwIc6W0VyNBfs/K4eE7wMgR1V48lQ80rEQKibC8kBHrXD2q+pqb
         6MwA==
ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816;
        h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post
         :list-id:mailing-list:precedence:reply-to:user-agent:in-reply-to
         :content-disposition:mime-version:references:mail-followup-to
         :message-id:subject:to:from:date:arc-authentication-results
         :arc-message-signature:dkim-signature:arc-authentication-results;
        bh=51TH+dQdnlrwCswYqKhmPDtdb0MWm1hVH/od2EbpT4o=;
        b=JkzTUXuqTbNsZ1fZxnDL7uPTAqhwF/O/a06K4FMjjF0tr9B1XoAOgzDAjgEYBM3J/A
         bzkbqIQ7vob0eqY96duV6TLr9PUT3CLpj3tfyq3PYc2BWZ1yoR7youVlkF6OQUPX0CvI
         NEjAeGVjJRd8/8IGUoKeocVfihI0Dtdeq9FldJA4LODJKcHTsfCQtZhjyBIqPXAI2+L+
         JFnfV9wT1K6iY3Dhof9gC2gPUJNBsW4/vSU6yoktpxUSzoa6afIHWMSRvrWtpr2N7n3H
         Ek7F0cUoa1FTl5MgYogoIapGGL6HubInFfLi+KCvFV29oujZskvNAtNoqgJNa0ys6QcR 
ARC-Authentication-Results: i=2; mx.google.com;
       spf=pass (google.com: domain of magfr@lysator.liu.se designates 2001:6b0:17:f0a0::3 as permitted sender) smtp.mailfrom=magfr@lysator.liu.se
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=isocpp-org.20150623.gappssmtp.com; s=20150623;
        h=date:from:to:subject:message-id:mail-followup-to:references
         :mime-version:content-disposition:in-reply-to:user-agent
         :x-original-sender:x-original-authentication-results:reply-to
         :precedence:mailing-list:list-id:list-post:list-help:list-archive
         :list-subscribe:list-unsubscribe;
        bh=51TH+dQdnlrwCswYqKhmPDtdb0MWm1hVH/od2EbpT4o=;
        b=RZBjFFrd/vEyeG8lknMCuAzqLkLVIdFLEtTfQwsWfMf1I+0Q3Q8CoH76+wzNLiDgnQ
         pdMH/sYHuzIk0yN6DTdFJ7sc4vtDvFizX6e4yfo1ksvzjPYlh5e4vJrrkuCM49KZ2pO2
         z1t6FKOdGP2c7eterOiNuIDtfJvoEpQ22LlL7dYfCn1hYJzK53m68hqHFgCE+Koq5m4F
         yHPDwJLLsvBa9Ya4OwaPsalQNBTTa8i+r3a3w2aXa8CwgtJLbT3C/ezfpF1B5r73q/hv
         2g1eVaWMsrfmZUqHu9F9Oeu2inMAwfy/+YcpeXRWto/O01FBYjMox0NNpXiWMtJ9C6VB
         k3wg==
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:subject:message-id:mail-followup-to
         :references:mime-version:content-disposition:in-reply-to:user-agent
         :x-original-sender:x-original-authentication-results:reply-to
         :precedence:mailing-list:list-id:x-spam-checked-in-group:list-post
         :list-help:list-archive:list-subscribe:list-unsubscribe;
        bh=51TH+dQdnlrwCswYqKhmPDtdb0MWm1hVH/od2EbpT4o=;
        b=RGsxPTRjL2UqspQY1TjVWP7ohL8zcMZet1ZoeNnRhdfd/96/guERFOMuodfaZpPi5u
         kpZz4sMrP0EckPFKEINfbmEmE+1iQASyEEZRp3fWD3DCzX06MiOh17fPIacXhkczAkcg
         sVOqtPo1HU4uaDi460CwjZDSAzh4TZnAqEmwzzWRalqJ5bgIr/vBUaT3wX60ueR/3YVY
         JHZAue+tseKN29w+QybWgUJpgAu+ktfJyAyzpRE4DfBQX4bj0qHsRL5D98yysuU757HX
         08SkHw7DldORxtRRSXVJzjxwpUjqD8rjMwS5zv8y12gbcJMmK/sdxp4kbxP 
X-Gm-Message-State: AKS2vOzRflPtXig49JH0gDr1zjqukCx33Qcky/3JRVXMAeFhgG6Xe3pf
	N//NzspXfMKrkNnO
X-Received: by 10.46.9.196 with SMTP id 187mr159922ljj.20.1498119890615;
        Thu, 22 Jun 2017 01:24:50 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.25.151.5 with SMTP id z5ls208422lfd.14.gmail; Thu, 22 Jun 2017
 01:24:48 -0700 (PDT)
X-Received: by 10.25.38.139 with SMTP id m133mr454814lfm.127.1498119888144;
        Thu, 22 Jun 2017 01:24:48 -0700 (PDT)
ARC-Seal: i=1; a=rsa-sha256; t=1498119888; cv=none;
        d=google.com; s=arc-20160816;
        b=ZtqBdKQyP/TyuuLkqqphtEidcergAGb+f2OEKN0Sbemc9g4yw0/aOI8uayu9iSl95r
         mLDQfIi/oCZToRvTNP+CiPX1bF/E4sZ5caW8xllN2zXyobrgsydJj2r61WfPmy2HTodr
         RCEA5v47vJKoAmJ4ojdYt/tMhpJp8T3KByW/fGSJDAXx4EJ5aqsI8nkD9RAGqYLQ3Zbv
         8Un7ujG5mKmsEDT9Apq1SLMufc1Q6FUM2ZRAvDYvugL+albmRKMwkTYxXd4Vn6yJimng
         23jGxaKdGdGAD54WUdnuvCCAdZH2TSMd9BVhSHsZeXINnfLr0mB7bK+mLc1kjvuFJJFv
         NCKQ==
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816;
        h=user-agent:in-reply-to:content-disposition:mime-version:references
         :mail-followup-to:message-id:subject:to:from:date
         :arc-authentication-results;
        bh=Xi18qLyg7JS4SvsOazNlBmwQxBvK4jfM/1aHQm5fXUI=;
        b=0LgYdsfvbVvc4XVGKR1SK5q+TqSfOBFZtFbYMyNksjn+t55xpRnPvM+OrOfAk/4Mlj
         lo/29/5+wpUiAEu5iVeDEmdZP4VL+R16w5iBh2D77IM5MR5TlMRMrujqk4D6XtYH+dZg
         WZvvxqy0GggCwPjqQAVesa/zkTytMdlVt4F7lSEg3uhFIdPXACIpCmFtg8RZlg4N+Fe7
         /A+yq5LPTMjtXh9UR2JX29ZhwjA9E8znF95HaX4rI+TlFaFJWVT9xA81m313gMioNzsP
         nDSSwz4IQL+C5QTWEDSc9e7MPKiKdW3VWC3fLod7HE/OHbivuCteEwoHy9W4XaQvv08K
         RXNA==
ARC-Authentication-Results: i=1; mx.google.com;
       spf=pass (google.com: domain of magfr@lysator.liu.se designates 2001:6b0:17:f0a0::3 as permitted sender) smtp.mailfrom=magfr@lysator.liu.se
Original-Received: from mail.lysator.liu.se (mail.lysator.liu.se. [2001:6b0:17:f0a0::3])
        by mx.google.com with ESMTPS id 6si422851ljf.333.2017.06.22.01.24.48
        for <std-proposals@isocpp.org>
        (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);
        Thu, 22 Jun 2017 01:24:48 -0700 (PDT)
Received-SPF: pass (google.com: domain of magfr@lysator.liu.se designates 2001:6b0:17:f0a0::3 as permitted sender) client-ip=2001:6b0:17:f0a0::3;
Original-Received: from mail.lysator.liu.se (localhost [127.0.0.1])
	by mail.lysator.liu.se (Postfix) with ESMTP id 6D21640011
	for <std-proposals@isocpp.org>; Thu, 22 Jun 2017 10:24:47 +0200 (CEST)
Original-Received: from noemi.bahnhof.se (h-155-4-132-137.NA.cust.bahnhof.se [155.4.132.137])
	(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
	(No client certificate requested)
	by mail.lysator.liu.se (Postfix) with ESMTPSA id 477034000F
	for <std-proposals@isocpp.org>; Thu, 22 Jun 2017 10:24:47 +0200 (CEST)
Mail-Followup-To: std-proposals@isocpp.org
Content-Disposition: inline
In-Reply-To: <d6138434-59ef-42d7-82d8-f2934c6f3bfb@isocpp.org>
X-Virus-Scanned: ClamAV using ClamSMTP
X-Original-Sender: magfr@lysator.liu.se
X-Original-Authentication-Results: mx.google.com;       spf=pass (google.com:
 domain of magfr@lysator.liu.se designates 2001:6b0:17:f0a0::3 as permitted
 sender) smtp.mailfrom=magfr@lysator.liu.se
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:32842
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/32842>

On Wed, Jun 21, 2017 at 08:02:35PM -0700, Mingxin Wang wrote:
> 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) {

Why remove_cv_t here?

>     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;

This is generally broken. Consider the folloving trivial data structure:

struct c_list {
	struct c_list *next, *prev;
	int data;
};

It is a trivial data structure but if you start moving (or copying) it around
with your wrapper things will break badly.

>   /* 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 think you need to put in a lot of more work on why they are generally
useful.

/MF

-- 
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/20170622082445.GA5007%40noemi.bahnhof.se.

.
