220 37353 <2555999.PcE7Su909f@tjmaciei-mobl1> article
Path: news.gmane.org!.POSTED!not-for-mail
From: Thiago Macieira <thiago@macieira.org>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: `offsetof` in a macro-less, modular world
Date: Thu, 15 Mar 2018 20:37:49 -0700
Lines: 32
Approved: news@gmane.org
Message-ID: <2555999.PcE7Su909f@tjmaciei-mobl1>
References: <c5f5ccc4-3267-442d-8cb2-de1ae103a38e@isocpp.org> <2319008.6H3YVR8kxN@tjmaciei-mobl1> <f8eb7785-19fb-d220-d06b-b973f051f283@gmail.com>
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 1521171390 19016 195.159.176.226 (16 Mar 2018 03:36:30 GMT)
X-Complaints-To: usenet@blaine.gmane.org
NNTP-Posting-Date: Fri, 16 Mar 2018 03:36:30 +0000 (UTC)
To: std-proposals@isocpp.org
Original-X-From: std-proposals+bncBCB4TK757YBRBN7YVTKQKGQE5N7RJEY@isocpp.org Fri Mar 16 04:36:25 2018
Return-path: <std-proposals+bncBCB4TK757YBRBN7YVTKQKGQE5N7RJEY@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-qk0-f197.google.com ([209.85.220.197])
	by blaine.gmane.org with esmtp (Exim 4.84_2)
	(envelope-from <std-proposals+bncBCB4TK757YBRBN7YVTKQKGQE5N7RJEY@isocpp.org>)
	id 1ewgAK-0004tS-TB
	for gclcip-std-proposals@m.gmane.org; Fri, 16 Mar 2018 04:36:25 +0100
Original-Received: by mail-qk0-f197.google.com with SMTP id x139sf5870429qkb.9
        for <gclcip-std-proposals@m.gmane.org>; Thu, 15 Mar 2018 20:38:32 -0700 (PDT)
ARC-Seal: i=2; a=rsa-sha256; t=1521171511; cv=pass;
        d=google.com; s=arc-20160816;
        b=HFxSY/AoCxKm79sRnh1htqDTpirMCx/JAhmR4fo6XUWUAn0akcf6Zac75Y4ihel0M5
         aFv/cOT32iB606ATaVvP+nhBc4mL7CH47/dFU+ywlRwDesmU5TX5aAIzOZ0AiERNfi21
         lQ7LTpjJG1z29l1EfFdTz65rTb8XLWnaVdMZTrT23YMCmB4JocsAnRALOZ79/ALX5wNm
         ElqDMBNMxaqIjKYeaOgc2VcOAenB+3hl0fVv4FSmNM3ceFQufeGbuTLKDowBQFq7AZjm
         w7RcaTN6HGDYSJ1zBpaysQOjczOnAxwci4gDotMe+h2C4GkeG+CjRFPlasTEujxTpmcI
         ICQg==
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:mime-version:references
         :in-reply-to:message-id:date:subject:to:from
         :arc-authentication-results:arc-message-signature:dkim-signature
         :arc-authentication-results;
        bh=RMHYbd6XVVyV/pkI7to2kiCud6suhP1JEJsRq9cJU5w=;
        b=sQ7R7VsuUjmyqWfiEkVNeEp9nFJYkK9MDraTJy0+VK52e9gwsbYR9Ccuk4H6HFUGmu
         Crkqg2KzOfRyenXu4GbK5xOMlq2mnktzczc3RWUjm3MQlj8I2UiYWGB0lmE691RRBd+B
         teM5ReLvu10tLGxIh3KXY6HWKvV3vsyzPDoqUuaRx5j/BZ9NlzD0IEs7UdYmjKvich/E
         4SwRV+rHLhvbm+R8t4OFrIiaN22I6Kw6m1Dm80mX/VebTl5pmeSFQKKD1MA5j8f2YEK5
         pRWp3NQXsTNPYP0ML8FB3UvQ0UugTT+iuycCOEaUzo7eMEM7zN73Yq+CgSHW2asfhLGN
         lwjg==
ARC-Authentication-Results: i=2; mx.google.com;
       spf=pass (google.com: domain of thiago@macieira.org designates 2001:19f0:5:2221::1:3 as permitted sender) smtp.mailfrom=thiago@macieira.org
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=isocpp-org.20150623.gappssmtp.com; s=20150623;
        h=from:to:subject:date:message-id:in-reply-to:references:mime-version
         :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=RMHYbd6XVVyV/pkI7to2kiCud6suhP1JEJsRq9cJU5w=;
        b=JXgWJd8jhDJXAQ11YGMV7KBb/cuodOXcgPJi3R/ky+2hZA2gnqM8Kyx/Z+FoshGvJ2
         36EbNb/2e27LfSw+4zS13vQSoMoBMADdKDv3V9FlwrN17O1JHjJgH6kXsT3/ZIpergKB
         7xpGnvtAfV/nV6Cn0M4QulQGMqByFqnYf8lEWNlfi8/84q7LCeYfGExyo32Uf3YkgTm9
         H+/cXXvdLZjuzduCs4iK5zKmJl2/0Oj1L3yPGvkA4sQrv5aGgJ23KboZYiSebn4oW+CV
         hFtLd9S6m85fqS84yk3Q0M6tnMf1JTV1I7cyLT8wyCQjDp2qmZK+9yZnYvN79q2rzAlf
         HW/Q==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20161025;
        h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to
         :references:mime-version: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=RMHYbd6XVVyV/pkI7to2kiCud6suhP1JEJsRq9cJU5w=;
        b=d+WNbLtMvCaqh3X/NBfM2/6XfsUqDRDxnH1JgTRQJoF+3Hbzr2U3sVoSiRMzsEaxLQ
         0hqbJaC/y1+EBXtXfjUSAEnKXhp0sUbYysLOF2qvZnNYEnsZJLphM5Z0C3Jy/BwxXR+S
         HgtkT3JxbYS8THMdP7xg5zsZ6lT4XKcQaNKKWa/OkPRYY6pgCN7y+hv9KHy+orrBuVkP
         3GD63SWld/KjmOC5U0Uc8PE++FIcVMPiyv6LsAXxCChmgrJNqQ29Zo2UbJC6CcqoYvtp
         KoD3umSLTngWserrSDfU10ovDWEVmCGuqHyKAPGvasMvJQw0ds9Mi+CXbWzsPE2//7BR
         h/9g==
X-Gm-Message-State: AElRT7EOzyhrcpI7xiKUCY4ApCpJ0jUw9ftigF44oWQmtvGIx1v2Nuja
	nSwXtbJrLDADK4VbTu81A67ivg==
X-Google-Smtp-Source: AG47ELscycXyg61Jjz7CbmUc/dhiXCevLWAVZ7vCCJENtpIj8WB9fp76uHLDSaj3EHosjMbv4HKGGg==
X-Received: by 10.55.75.23 with SMTP id y23mr175236qka.16.1521171511802;
        Thu, 15 Mar 2018 20:38:31 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.55.77.8 with SMTP id a8ls3619625qkb.3.gmail; Thu, 15 Mar 2018
 20:38:30 -0700 (PDT)
X-Received: by 10.55.81.10 with SMTP id f10mr381396qkb.21.1521171510708;
        Thu, 15 Mar 2018 20:38:30 -0700 (PDT)
ARC-Seal: i=1; a=rsa-sha256; t=1521171510; cv=none;
        d=google.com; s=arc-20160816;
        b=Fd5pl0hc7d4WJeFk1B1izNpSHm4HR9xO1BOd95De3Sbq+rLlixLyhqpHQTyc7sMTgr
         RAIwn63bFoVYuGXmpM/Tn/jUtbIwYq2AIeG46egPOm/vPLW6OuoOA8Mt11ICoCSkNz5B
         C9D4sNlUYONUWShg8FrOBUzdd6lF4c9vV9pVzuAI2fyYrc45xQ7m3tyYzoQ9yWPLfghG
         qpS6FqQcRwyHQ9Xyk5ZP1hLKsUYI1Pb9GUJQnfIbUUxPlnfXobvwXyHJDgSVJsfyBxFp
         JfY5lh8JrAG4+deyQQ+0zhAncb61sm+87YOkobv3RezxICM1JLdovbEOvDl1rBF/3gX5
         T14g==
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816;
        h=content-transfer-encoding:mime-version:references:in-reply-to
         :message-id:date:subject:to:from:arc-authentication-results;
        bh=zE7VakkdWajlmf9hFXwwgFoPpZEd6fySdA7mURwAsyM=;
        b=y5yUVjYSfhnxO2BjLOw3xnIuBlkAhOLo0dwxZB1NhIEpNyna+BsLLbF2zIFy8ppEB3
         ZDd+2AQ25EnLMN7uHhqw3p1bnjsIilM4/lO8tAppuG1NuEWNdiIjAuxYt9NPCeq4VYMg
         A98yRQhtRVrIOhkKOrNPdmUgzjV1EM9vynbvgwHTr444dH/ZrkESiOpc5eKZbpzv4Xub
         VQfxHeSKNvztykZHa0S7l0zsl6I1sZlNRTrFFtCWrbkNy2493xoOLEyE/RZiXQqouj0q
         wLZRqlUrFEjAqVyCptKUsml6voi0/PtEKy2uObzUW5H3SVQBaDfiC8OGepTITDfYT1IA
         u7xQ==
ARC-Authentication-Results: i=1; mx.google.com;
       spf=pass (google.com: domain of thiago@macieira.org designates 2001:19f0:5:2221::1:3 as permitted sender) smtp.mailfrom=thiago@macieira.org
Original-Received: from smtp.macieira.info (smtp.macieira.info. [2001:19f0:5:2221::1:3])
        by mx.google.com with ESMTPS id p24si3041211qkp.80.2018.03.15.20.38.30
        for <std-proposals@isocpp.org>
        (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);
        Thu, 15 Mar 2018 20:38:30 -0700 (PDT)
Received-SPF: pass (google.com: domain of thiago@macieira.org designates 2001:19f0:5:2221::1:3 as permitted sender) client-ip=2001:19f0:5:2221::1:3;
Original-Received: from tjmaciei-mobl1.localnet (unknown [IPv6:2601:1c0:4501:5f9f:cdd9:d8c0:f4a1:41bc])
	by smtp.macieira.info (Postfix) with ESMTPSA id 50687A67B
	for <std-proposals@isocpp.org>; Thu, 15 Mar 2018 20:38:29 -0700 (PDT)
In-Reply-To: <f8eb7785-19fb-d220-d06b-b973f051f283@gmail.com>
X-Original-Sender: thiago@macieira.org
X-Original-Authentication-Results: mx.google.com;       spf=pass (google.com:
 domain of thiago@macieira.org designates 2001:19f0:5:2221::1:3 as permitted
 sender) smtp.mailfrom=thiago@macieira.org
Precedence: list
Mailing-list: list std-proposals@isocpp.org; contact std-proposals+owners@isocpp.org
List-ID: <std-proposals.isocpp.org>
X-Spam-Checked-In-Group: 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:37353
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/37353>

On Thursday, 15 March 2018 18:05:52 PDT Andrey Semashev wrote:
> > Why not? We can if we give ourselves the syntax for it.
> 
> Well, we don't have one now, that's why you can't do that. We need at
> least a proposal for this new syntax to have a meaningful comparison
> with offsetof.

Right. I'm just saying that we should use pointer-to-members instead, since 
they would also give us type safety, something that offsetof can't do.

> > 	int A:: *int_in_A = &A::y;	// just so we don't discuss arrays just now
> > 	A B:: *A_in_B = &B::a;
> > 	int B:: *int_in_B = int_in_A + A_in_B;	// syntax TBD
> 
> Right, that illustrates what I called "much more difficult". offsetof is
> pretty difficult to beat in code conciseness and clarity.

But you get an offset, which breaks a lot of assumptions in the type system. 
It's not really easy to use.

-- 
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
   Software Architect - Intel Open Source Technology Center



-- 
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/2555999.PcE7Su909f%40tjmaciei-mobl1.

.
