220 29388 <CAOqAUTiRxwtmzM-_tSyTUKbyiJhivCbVmUgQ749ByD=h-SAF4A@mail.gmail.com> article
Path: news.gmane.org!.POSTED!not-for-mail
From: Mikhail Maltsev <maltsevm@gmail.com>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: why not formally support meta programming.
Date: Wed, 9 Nov 2016 11:46:40 -0800
Lines: 64
Approved: news@gmane.org
Message-ID: <CAOqAUTiRxwtmzM-_tSyTUKbyiJhivCbVmUgQ749ByD=h-SAF4A@mail.gmail.com>
References: <668e0a04-c988-4354-ae32-30f626f75403@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 1478720806 5920 195.159.176.226 (9 Nov 2016 19:46:46 GMT)
X-Complaints-To: usenet@blaine.gmane.org
NNTP-Posting-Date: Wed, 9 Nov 2016 19:46:46 +0000 (UTC)
To: std-proposals@isocpp.org
Original-X-From: std-proposals+bncBCTMPSET54IRBIX2RXAQKGQE7W4KJNI@isocpp.org Wed Nov 09 20:46:42 2016
Return-path: <std-proposals+bncBCTMPSET54IRBIX2RXAQKGQE7W4KJNI@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-wm0-f72.google.com ([74.125.82.72])
	by blaine.gmane.org with esmtp (Exim 4.84_2)
	(envelope-from <std-proposals+bncBCTMPSET54IRBIX2RXAQKGQE7W4KJNI@isocpp.org>)
	id 1c4YpU-0000sW-CI
	for gclcip-std-proposals@m.gmane.org; Wed, 09 Nov 2016 20:46:40 +0100
Original-Received: by mail-wm0-f72.google.com with SMTP id g23sf38685996wme.4
        for <gclcip-std-proposals@m.gmane.org>; Wed, 09 Nov 2016 11:46:43 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=isocpp-org.20150623.gappssmtp.com; s=20150623;
        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:x-spam-checked-in-group:list-post
         :list-help:list-archive:list-subscribe:list-unsubscribe;
        bh=0Ub3fgQdBstYBtwGuhsoYgFWA8PpCUAt8NrUnZRXbs4=;
        b=hHcMsdvikK8wbkbwSmnVBFfoRH2odExS/Wp5fjDvAvD/tgJtS2edhyR3FaEcWfzj9t
         wjm5SGVDjKdXdTnLHQ1vR1wtL3F1n5Cza0CuG2xZi9PdynsyqVu34Umtv/a/0CwO1QdQ
         twXKd+mkJMTk4cUjW+AeWztx6ybAr5OQcnQxFlUPOzD6yg7BbVqXBT7MI8BJycB/PCix
         c0Z6kTt6F0MO8owyffxvVokQKO9606bnn0XHBDSYbuTgApHT3RmqDsZWaYJDeOTibyWo
         Ml1RuHfhm38jtxW6+Ax+5S8DKDD5MusEV2yMIDjjjajXNs1QJUVIsAwMA0+WotxrBY6W
         XGmw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20130820;
        h=x-gm-message-state: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:x-spam-checked-in-group:list-post:list-help:list-archive
         :list-subscribe:list-unsubscribe;
        bh=0Ub3fgQdBstYBtwGuhsoYgFWA8PpCUAt8NrUnZRXbs4=;
        b=aSYZ0JuThCVMIYKCKZIyGtMrCvnu8fh1Sh1LLehgrtp5jFlK3a5Eg+8UuejpCTs+c/
         lpfygURnJ5J6XSk2ezQVPwXkL5wk2UdxxOsuFvACyYISHTJL94RDGLhfvDAOlKaT2I0C
         O8Z0WVS4CDGp9gjzlXhfCYarBsqUrILqSB4OWGKCKPffMoARYcuShxc3o0NnLBIBa4Fl
         Ooey+5/9OOsLFNam84CuGyjDgabC+7QUrZcwjJClTCDIUJRlnSqSTkht9i6NumE264fD
         kbWZmEwdejSa67UtFj2wAUT06VHJFgGdLmulUOQvjRIdfxW5+My5BirvVPjxjfLOFs22
         EhGQ==
X-Gm-Message-State: ABUngvfYoYOTFO7N3leEmgMvkD5UZ/VPGHSxzt0kfJwqEFR/N6nIVIzxTUBPLcU3cCLucQ==
X-Received: by 10.28.63.213 with SMTP id m204mr322617wma.21.1478720803487;
        Wed, 09 Nov 2016 11:46:43 -0800 (PST)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.28.228.136 with SMTP id b130ls1568215wmh.0.gmail; Wed, 09 Nov
 2016 11:46:42 -0800 (PST)
X-Received: by 10.28.109.87 with SMTP id i84mr2052827wmc.100.1478720802194;
        Wed, 09 Nov 2016 11:46:42 -0800 (PST)
Original-Received: from mail-wm0-x22d.google.com (mail-wm0-x22d.google.com. [2a00:1450:400c:c09::22d])
        by mx.google.com with ESMTPS id xy10si1127940wjb.253.2016.11.09.11.46.42
        for <std-proposals@isocpp.org>
        (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);
        Wed, 09 Nov 2016 11:46:42 -0800 (PST)
Received-SPF: pass (google.com: domain of maltsevm@gmail.com designates 2a00:1450:400c:c09::22d as permitted sender) client-ip=2a00:1450:400c:c09::22d;
Original-Received: by mail-wm0-x22d.google.com with SMTP id f82so263287573wmf.1
        for <std-proposals@isocpp.org>; Wed, 09 Nov 2016 11:46:42 -0800 (PST)
X-Received: by 10.194.109.168 with SMTP id ht8mr1211315wjb.36.1478720801632;
 Wed, 09 Nov 2016 11:46:41 -0800 (PST)
Original-Received: by 10.80.175.4 with HTTP; Wed, 9 Nov 2016 11:46:40 -0800 (PST)
In-Reply-To: <668e0a04-c988-4354-ae32-30f626f75403@isocpp.org>
X-Original-Sender: maltsevm@gmail.com
X-Original-Authentication-Results: mx.google.com;       dkim=pass
 header.i=@gmail.com;       spf=pass (google.com: domain of maltsevm@gmail.com
 designates 2a00:1450:400c:c09::22d as permitted sender) smtp.mailfrom=maltsevm@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: <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:29388
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/29388>

On Wed, Nov 9, 2016 at 11:32 AM,  <billconan@gmail.com> wrote:
> I'm trying to design a library for different hardware (CPU and GPU)
>
> For users, I want the interface looks like this:
>
>
> Blah<GPU, float> b();
>
> or
>
> Blah<CPU, double> c();
>
>
> ideally inside the class of Blah, I want to do this to avoid duplication and
> reduce workload:
>
>
>
> template<DeviceType deviceUsed, typename DataType>
> class Blah
> {
>       DataType shared_member;
>
>
>       #Meta_if(deviceUsed == GPU)   //some kind of meta programming syntax
> to enable code based on template
>       #{
>            DataType member_only_used_by_gpu;
>            void function_on_gpu();
>       #}
>
>
>       #Meta_if(deviceUsed == CPU)
>       #{
>           DataType member_only_used_by_cpu;
>           void function_on_cpu();
>       #}
>
>
>
>
>       void shared_function()
>       {
>             ....
>             #Meta_if(deviceUsed = GPU) {
>            ....
>             #}
>       }
> };
>
C++17 will have constexpr if. It can be used in a function, but not in
a class definition. Actually the latter has been proposed earlier, but
rejected: https://isocpp.org/files/papers/n3613.pdf

-- 
Regads,
   Mikhail Maltsev

-- 
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/CAOqAUTiRxwtmzM-_tSyTUKbyiJhivCbVmUgQ749ByD%3Dh-SAF4A%40mail.gmail.com.

.
