220 10406 <CAB+4KHKqB1NC=HYjrZSm=Brj7-Vh50ovTJjnJYpq-Css+mUssw@mail.gmail.com> article
Path: news.gmane.org!not-for-mail
From: Andrew Tomazos <andrewtomazos@gmail.com>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: Generated initializer_list
Date: Mon, 28 Apr 2014 13:01:29 +0200
Lines: 66
Approved: news@gmane.org
Message-ID: <CAB+4KHKqB1NC=HYjrZSm=Brj7-Vh50ovTJjnJYpq-Css+mUssw@mail.gmail.com>
References: <357dd72f-c749-4dc5-aa6d-5ac4528aba5a@isocpp.org>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: plane.gmane.org
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
X-Trace: ger.gmane.org 1398682899 23232 80.91.229.3 (28 Apr 2014 11:01:39 GMT)
X-Complaints-To: usenet@ger.gmane.org
NNTP-Posting-Date: Mon, 28 Apr 2014 11:01:39 +0000 (UTC)
To: std-proposals@isocpp.org
Original-X-From: std-proposals+bncBD5KHQXXWYPRBCXK7CNAKGQEHPDAZOY@isocpp.org Mon Apr 28 13:01:33 2014
Return-path: <std-proposals+bncBD5KHQXXWYPRBCXK7CNAKGQEHPDAZOY@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-la0-f70.google.com ([209.85.215.70])
	by plane.gmane.org with esmtp (Exim 4.69)
	(envelope-from <std-proposals+bncBD5KHQXXWYPRBCXK7CNAKGQEHPDAZOY@isocpp.org>)
	id 1WejJT-0000kC-Ju
	for gclcip-std-proposals@m.gmane.org; Mon, 28 Apr 2014 13:01:31 +0200
Original-Received: by mail-la0-f70.google.com with SMTP id gl10sf994772lab.5
        for <gclcip-std-proposals@m.gmane.org>; Mon, 28 Apr 2014 04:01:31 -0700 (PDT)
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:date
         :message-id:subject:from: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=f9m4bU0gtxSI72gVBXvO/0fE9Z6+j7wfL/dvwGvP0vQ=;
        b=Jv4pQAeH0dFf3WHyWf7csLldCmlCFzw5zsrsv1B1i/zyxrAC4DRk6Ee7Cb4Ifveo4z
         ma+cNnoXUqni81JgyQM86SNOM4Ewid6jCTYYrUSLNZmxyJVxinpTnDK2cQtFLsOcbTX+
         E+NHkbXGzgXZohunEgmJeF/ra1I9X+ykyllaE5s5+UkST1ZTyWSWpDZwmPYl3qMtjQna
         OmCatPZLkFIyW1dv+M7hFPREeE4S+W5YRUZyX5p0mPW0Hum3dtul7F/LUoCEuV9me0/G
         WatX5r454/vqTx+VeVdJhvJm+Qe51VX2+zXIAV8t79/daUS1m5nXPduMvfRtHD/cQOww
         UdpQ==
X-Gm-Message-State: ALoCoQldI0Skt2YURnNflJVTZEyUzAUmJbh+hdSHarzJeL9dKEOHJO6HJn51c5Fxa0og69iW9XBC
X-Received: by 10.152.3.38 with SMTP id 6mr2010966laz.0.1398682891359;
        Mon, 28 Apr 2014 04:01:31 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.180.104.41 with SMTP id gb9ls164234wib.28.canary; Mon, 28 Apr
 2014 04:01:30 -0700 (PDT)
X-Received: by 10.180.72.205 with SMTP id f13mr14916784wiv.45.1398682890090;
        Mon, 28 Apr 2014 04:01:30 -0700 (PDT)
Original-Received: from mail-wg0-x232.google.com (mail-wg0-x232.google.com [2a00:1450:400c:c00::232])
        by mx.google.com with ESMTPS id dm4si3440547wib.8.2014.04.28.04.01.30
        for <std-proposals@isocpp.org>
        (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128);
        Mon, 28 Apr 2014 04:01:30 -0700 (PDT)
Received-SPF: pass (google.com: domain of andrewtomazos@gmail.com designates 2a00:1450:400c:c00::232 as permitted sender) client-ip=2a00:1450:400c:c00::232;
Original-Received: by mail-wg0-f50.google.com with SMTP id k14so1747391wgh.9
        for <std-proposals@isocpp.org>; Mon, 28 Apr 2014 04:01:29 -0700 (PDT)
X-Received: by 10.180.85.10 with SMTP id d10mr19601313wiz.0.1398682889748;
 Mon, 28 Apr 2014 04:01:29 -0700 (PDT)
Original-Received: by 10.227.203.71 with HTTP; Mon, 28 Apr 2014 04:01:29 -0700 (PDT)
In-Reply-To: <357dd72f-c749-4dc5-aa6d-5ac4528aba5a@isocpp.org>
X-Original-Sender: andrewtomazos@gmail.com
X-Original-Authentication-Results: mx.google.com;       spf=pass (google.com:
 domain of andrewtomazos@gmail.com designates 2a00:1450:400c:c00::232 as
 permitted sender) smtp.mail=andrewtomazos@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:10406
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/10406>

To represent a compile-time sequence of values of a given literal type
T you can use an array defined with constexpr:

    constexpr T a[] = ...;

If the values differ in type you can use a class type of literal type:

    constexpr struct
    {
         T1 v1;
         T2 v2;
         T3 v3;
    } S = ...;

There are a few other options, but it isn't clear from your example
what the problem is with the above.  In all cases you can write a
constexpr function that returns the above types (well, you need to
wrap the array in a struct to return it as usual).  You can create a
mutable local variable of the type within the constexpr function, fill
it out, and return it:

There are some limitations on literal types that different people are
thinking about and working on, but it isn't clear which one (if any)
you are hitting upon.



On Mon, Apr 28, 2014 at 12:32 PM,  <douglas.boffey@gmail.com> wrote:
> It appears to me that one feature that is missing from most languages is a
> method to compile-time compute a sequence (e.g. an array, etc.)  One way to
> do this is a program (e.g. yacc) that generates a compilation unit.  Surely
> the time is now ripe, with C++11's initializer_lists and C++14's relaxed
> rules for constexprs to be able to directly code the algorithm withing the
> compilation unit.
>
> Maybe something along the lines of:
>
> template<typename ValueType, typename Object, typename Args...>
> std::initializer_list<ValueType> make_initializer_list(Object object,
> Args... args) {
>   initializer_list<ValueType> result {};
>   while (object.more())
>     result.push_back(object());
>   return result;
> }
>
>
> --
>
> ---
> 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/.

.
