220 8141 <fcb910ab-7d1b-4622-a58a-e51a8b781dbc@isocpp.org> article
Path: news.gmane.org!not-for-mail
From: Sean Middleditch <sean.middleditch@gmail.com>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: A compile-time string literal library type
Date: Mon, 16 Dec 2013 11:22:56 -0800 (PST)
Lines: 83
Approved: news@gmane.org
Message-ID: <fcb910ab-7d1b-4622-a58a-e51a8b781dbc@isocpp.org>
References: <d9fcae4a-7452-4660-8053-1386f851951f@isocpp.org>
 <CAGsORuAv7xKEXMsUfWd04tkBULXRVM90RqQguJfdqkX1KbLsPg@mail.gmail.com>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: plane.gmane.org
Mime-Version: 1.0
Content-Type: multipart/alternative; 
	boundary="----=_Part_298_25847591.1387221776802"
X-Trace: ger.gmane.org 1387221776 28167 80.91.229.3 (16 Dec 2013 19:22:56 GMT)
X-Complaints-To: usenet@ger.gmane.org
NNTP-Posting-Date: Mon, 16 Dec 2013 19:22:56 +0000 (UTC)
To: std-proposals@isocpp.org
Original-X-From: std-proposals+bncBCDODCNR2QPRBENGXWKQKGQEHISNW6Y@isocpp.org Mon Dec 16 20:23:02 2013
Return-path: <std-proposals+bncBCDODCNR2QPRBENGXWKQKGQEHISNW6Y@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-ve0-f197.google.com ([209.85.128.197])
	by plane.gmane.org with esmtp (Exim 4.69)
	(envelope-from <std-proposals+bncBCDODCNR2QPRBENGXWKQKGQEHISNW6Y@isocpp.org>)
	id 1Vsdkp-0002FR-30
	for gclcip-std-proposals@m.gmane.org; Mon, 16 Dec 2013 20:22:59 +0100
Original-Received: by mail-ve0-f197.google.com with SMTP id oz11sf10423286veb.0
        for <gclcip-std-proposals@m.gmane.org>; Mon, 16 Dec 2013 11:22:58 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20120113;
        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
         :content-type;
        bh=WKJ9VsfPHIChKkEMMDAzENZCNOblqT34a+rL6z6EQkA=;
        b=reUkAEZ6Ul0a2KYnu2jPcd72oN87KKUgsFl0OrzSWeF72QlInc3F+cwid6+nl67IFQ
         5jp5miDaEIvwW/JZb9bJrgdNf7LJoP4qgP9c0ghJM5G0QmKfNsM4F1Y0aW6tB5BXufm7
         R8ihG30OBe8ddJND+tb7PAX/Oxx27mqNXCeGPhhGoUOZOif6NYYX55r4mgVJa3DcUJzE
         w4uTfv0/NJQnrT28YkB59Mqqfk5WRBkS4WiL+hPGC83Ocu9OrHaSX/e0XSHHP7awXjg6
         0CFKCNIwCk2A+JvVM9RdCXrlnNWlTPKJFtrLIfx/28Nr9g8ya5uAVV2mbDfbWjpgLXXk
         Xj0Q==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20130820;
        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:list-post:list-help:list-archive
         :list-subscribe:list-unsubscribe:content-type;
        bh=WKJ9VsfPHIChKkEMMDAzENZCNOblqT34a+rL6z6EQkA=;
        b=MaiBclQ19biemOYhvVi4hwALMqqJWpJAhn8J6pmq3py1npxdJVhFUjC+RGdgF2BglV
         Huuij2aOHycKTLS/bGiBQpEFLdhKf27u1LTwqR4PLQa4e6yaTnV8CF/+zHTKnzXISl9P
         hWxo6AzWOkfWH5udygvqL6HHwXRMv/ODmnySCoE8zCpQHzf+WFj0k9eB2h+AI4vza8AM
         Dbb6nRKmdezbEeTUoB/K7c3sYEAHVZuN6GBMaLolagEQMVh+NqzGhwAfii72EXMm2qB/
         Pqv7HG/Iy+MoGDlG5VqI5uPA9SeKr9KaVk5jsLIASJkz93gDCTXdqm6FNSHXCM5fonqq
         5YvQ==
X-Gm-Message-State: ALoCoQkD9EVkp7Bmm2AKgmnw6q+BXHnylnsD6C4qvuK3CkYluWthM7IsnCn8XdjWgmns+hYRG7ms
X-Received: by 10.58.118.231 with SMTP id kp7mr1184871veb.36.1387221778270;
        Mon, 16 Dec 2013 11:22:58 -0800 (PST)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.49.131.162 with SMTP id on2ls2217970qeb.73.gmail; Mon, 16 Dec
 2013 11:22:57 -0800 (PST)
X-Received: by 10.49.16.168 with SMTP id h8mr454869qed.2.1387221777526;
        Mon, 16 Dec 2013 11:22:57 -0800 (PST)
In-Reply-To: <CAGsORuAv7xKEXMsUfWd04tkBULXRVM90RqQguJfdqkX1KbLsPg@mail.gmail.com>
X-Original-Sender: sean.middleditch@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:8141
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/8141>

------=_Part_298_25847591.1387221776802
Content-Type: text/plain; charset=ISO-8859-1

On Sunday, December 15, 2013 8:52:52 PM UTC-8, Zhihao Yuan wrote:
>
>
>  3. need use cases. 
>
>
We use a string literal wrapper to allow compile-time string hashing for 
big efficiency gains when using fixed known keys in hash tables.  This need 
comes up a lot with parsing (XML, JSON, INI config files, www-urlencoded 
POST requests, HTTP headers, command and script languages, etc.).

Given the proper interfaces to a hash table, you can have overloads or 
extra methods so that lookups with pre-computed hashes are possible and you 
can avoid the overhead of the hash function.  For smaller tables the hash 
function can be almost as expensive (or more expensive) than the bucket 
lookup and value traversal, especially if you are using a slightly 
non-conforming unordered_map replacement that uses certain open addressing 
algorithms (which might mean iterators get invalidated during insert/erase 
even without rehashing.)

Given the current lack of some essential C++11 features in a very popular 
compiler we end up using a few hacks.  One common one I see a lot is to use 
a macro like HASH_STR("literal") and then a preprocessor to find and 
replace all those with hash results.  Obviously that is far from ideal, 
though there are plenty of other needs for a specialized pre-processor in 
C++ today (it's one way to implement reflection for serialization and 
editor data binding).

-- 

--- 
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/.

------=_Part_298_25847591.1387221776802
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">On Sunday, December 15, 2013 8:52:52 PM UTC-8, Zhihao Yuan=
 wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.=
8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><br>&nbsp;3. need use c=
ases.
<br><br></blockquote><div><br></div><div>We use a string literal wrapper to=
 allow compile-time string hashing for big efficiency gains when using fixe=
d known keys in hash tables. &nbsp;This need comes up a lot with parsing (X=
ML, JSON, INI config files, www-urlencoded POST requests, HTTP headers, com=
mand and script languages, etc.).</div><div><br></div><div>Given the proper=
 interfaces to a hash table, you can have overloads or extra methods so tha=
t lookups with pre-computed hashes are possible and you can avoid the overh=
ead of the hash function. &nbsp;For smaller tables the hash function can be=
 almost as expensive (or more expensive) than the bucket lookup and value t=
raversal, especially if you are using a slightly non-conforming unordered_m=
ap replacement that uses certain open addressing algorithms (which might me=
an iterators get invalidated during insert/erase even without rehashing.)</=
div><div><br></div><div>Given the current lack of some essential C++11 feat=
ures in a very popular compiler we end up using a few hacks. &nbsp;One comm=
on one I see a lot is to use a macro like HASH_STR("literal") and then a pr=
eprocessor to find and replace all those with hash results. &nbsp;Obviously=
 that is far from ideal, though there are plenty of other needs for a speci=
alized pre-processor in C++ today (it's one way to implement reflection for=
 serialization and editor data binding).</div></div>

<p></p>

-- <br />
&nbsp;<br />
--- <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 std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />

------=_Part_298_25847591.1387221776802--

.
