220 8143 <52AF8782.1070405@gmail.com> article
Path: news.gmane.org!not-for-mail
From: David Krauss <potswa@gmail.com>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: A compile-time string literal library type
Date: Tue, 17 Dec 2013 07:06:42 +0800
Lines: 33
Approved: news@gmane.org
Message-ID: <52AF8782.1070405@gmail.com>
References: <d9fcae4a-7452-4660-8053-1386f851951f@isocpp.org>	<CAGsORuAv7xKEXMsUfWd04tkBULXRVM90RqQguJfdqkX1KbLsPg@mail.gmail.com>	<52AE9F22.1070403@gmail.com> <CAGsORuD5Zza0CcxL7FrpkxMsXX0duXGgzfsimFobTEKBhxydKg@mail.gmail.com>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: plane.gmane.org
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
X-Trace: ger.gmane.org 1387235204 18361 80.91.229.3 (16 Dec 2013 23:06:44 GMT)
X-Complaints-To: usenet@ger.gmane.org
NNTP-Posting-Date: Mon, 16 Dec 2013 23:06:44 +0000 (UTC)
To: std-proposals@isocpp.org
Original-X-From: std-proposals+bncBCW25A7E3QCRBCEPX2KQKGQECJK43LY@isocpp.org Tue Dec 17 00:06:50 2013
Return-path: <std-proposals+bncBCW25A7E3QCRBCEPX2KQKGQECJK43LY@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-yh0-f69.google.com ([209.85.213.69])
	by plane.gmane.org with esmtp (Exim 4.69)
	(envelope-from <std-proposals+bncBCW25A7E3QCRBCEPX2KQKGQECJK43LY@isocpp.org>)
	id 1VshFR-0000bL-Va
	for gclcip-std-proposals@m.gmane.org; Tue, 17 Dec 2013 00:06:50 +0100
Original-Received: by mail-yh0-f69.google.com with SMTP id a41sf10660476yho.4
        for <gclcip-std-proposals@m.gmane.org>; Mon, 16 Dec 2013 15:06:49 -0800 (PST)
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20130820;
        h=x-gm-message-state:message-id:date:from:user-agent:mime-version:to
         :subject:references:in-reply-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=3ImXG35zwCMwt6zeMYvuaRxkIqI8EwwzZLAZuq7WGOE=;
        b=AxONvMPbQEOx/zuz0JpzUSL9Wqxq39fkwPJM0sh/ZEvbtZ/bvEu4tMtOawvbf3SW52
         409lOqKCuUYJxpmRueDSYPwGlZkXQgVwDUh2v9bVfWsj9aKH0rzmWHfbr5j/d3MHfmT3
         cyi0lEEL9ofzu56/hWVJ5QM9ujZ41LBOoK5UNHMPtMDZHdOt5qv4fKABPFVIsazv822Z
         iJUWeuP6N38+4dg4oD4BZNlIrpjKlX9M/7u+bchLzvtqpA7NLWox+vOnTbSOpM3UO4cr
         7E8dbsacPo53gWHxORw38rLu2nIqQXsC8DFNT5+3SV+/m/sIFDb0QRIHp+4cy8lpECFV
         daGw==
X-Gm-Message-State: ALoCoQn4xTCyNXn26KmV9rRUDSNg+8wbMr5EgXQ3jNSd3DAD5fkcbOnKJUCLxiOCiYrFyrmkRJr5
X-Received: by 10.52.159.99 with SMTP id xb3mr6141909vdb.4.1387235209006;
        Mon, 16 Dec 2013 15:06:49 -0800 (PST)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.49.3.228 with SMTP id f4ls2332699qef.85.gmail; Mon, 16 Dec
 2013 15:06:48 -0800 (PST)
X-Received: by 10.236.160.9 with SMTP id t9mr15079790yhk.10.1387235208187;
        Mon, 16 Dec 2013 15:06:48 -0800 (PST)
Original-Received: from mail-pa0-x22b.google.com (mail-pa0-x22b.google.com [2607:f8b0:400e:c03::22b])
        by mx.google.com with ESMTPS id j69si13885395yhb.246.2013.12.16.15.06.48
        for <std-proposals@isocpp.org>
        (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128);
        Mon, 16 Dec 2013 15:06:48 -0800 (PST)
Received-SPF: pass (google.com: domain of potswa@gmail.com designates 2607:f8b0:400e:c03::22b as permitted sender) client-ip=2607:f8b0:400e:c03::22b;
Original-Received: by mail-pa0-f43.google.com with SMTP id bj1so3607734pad.2
        for <std-proposals@isocpp.org>; Mon, 16 Dec 2013 15:06:47 -0800 (PST)
X-Received: by 10.68.29.72 with SMTP id i8mr23604484pbh.116.1387235207223;
        Mon, 16 Dec 2013 15:06:47 -0800 (PST)
Original-Received: from Davids-MacBook-Pro.local ([121.54.54.135])
        by mx.google.com with ESMTPSA id ug2sm39846627pac.21.2013.12.16.15.06.44
        for <std-proposals@isocpp.org>
        (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128);
        Mon, 16 Dec 2013 15:06:46 -0800 (PST)
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:24.0) Gecko/20100101 Thunderbird/24.2.0
In-Reply-To: <CAGsORuD5Zza0CcxL7FrpkxMsXX0duXGgzfsimFobTEKBhxydKg@mail.gmail.com>
X-Original-Sender: potswa@gmail.com
X-Original-Authentication-Results: mx.google.com;       spf=pass (google.com:
 domain of potswa@gmail.com designates 2607:f8b0:400e:c03::22b as permitted
 sender) smtp.mail=potswa@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:8143
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/8143>

On 12/16/13 11:44 PM, Zhihao Yuan wrote:
> On Mon, Dec 16, 2013 at 1:35 AM, David Krauss <potswa@gmail.com> wrote:
>> Right now I'm making due with an imperfect constexpr hash:
>> [...]
>>
>> The ud-string-literal is used directly as a non-type template argument, so
>> it must have scalar type, which cannot contain more information than a
>> std::intmax_t, or else be a reference to global, which seemingly cannot be
>> generated suitably. Another way of looking at this is not the need for
>> template string arguments, but the need for a non-type template argument
>> that can uniquely encode arbitrarily much data, and can be returned from a
>> ud-string-literal function.
> AFAICS all you are building is a symbol table, then why not ask for a
> language feature like, a symbol type?  Compiler builds symbol table
> cheaper and nicer then you do :)

I do also perform the same hash on user input as a proxy for string 
equality. When this is not required, I use an elaborated-type-specifier 
for local declaration of a namespace-member, incomplete class.

My use case sounds similar to Sean Middleditch's. If the declarations 
were at namespace scope, and they contained two copies of the literal 
(likely job for a macro), then the declared objects could have a proper 
copy of the string to catch collisions.

-- 

--- 
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/.

.
