From 589069758496346807
X-Google-Thread: f78e5,6f5c74c3d7959916
X-Google-NewGroupId: yes
X-Google-Attributes: gid7894ca11fe,domainid0,public,usenet
X-Google-Language: ENGLISH,ASCII
Received: by 10.205.123.140 with SMTP id gk12mr1412744bkc.1.1335552427985;
        Fri, 27 Apr 2012 11:47:07 -0700 (PDT)
MIME-Version: 1.0
Path: h15ni172450bkw.0!nntp.google.com!news2.google.com!feed-C.news.volia.net!volia.net!news2.volia.net!feed-A.news.volia.net!news.musoftware.de!wum.musoftware.de!news.albasani.net!.POSTED!not-for-mail
From: =?ISO-8859-1?Q?Daniel_Kr=FCgler?=<daniel.kruegler@googlemail.com>
Newsgroups: comp.std.c++
Subject: Re: make_shared and friends.
Date: Fri, 27 Apr 2012 11:47:05 -0700 (PDT)
Organization: A noiseless patient Spider
Lines: 60
Sender: std-cpp-request@vandevoorde.com
Approved: stephen.clamage@oracle.com
Message-ID: <jnep30$d2s$1@dont-email.me>
References: <5583145.28.1335476739188.JavaMail.geo-discussion-forums@ynnn35>
NNTP-Posting-Host: 59a5709Lq5cj+MZsL3OTCQEiT06OEPm1ioj3UzpKNbk=
X-Trace: news.albasani.net NlCKhjfdTMdOCjSFClns2tt1GnuumLqTz/RboVBJWjsZiytZ19Uek8x0s4O4SRmdLGnP4y8UkoGCAv7c+6G9zg==
X-Complaints-To: abuse@albasani.net
NNTP-Posting-Date: Fri, 27 Apr 2012 18:47:07 +0000 (UTC)
X-Mailer: Perl5 Mail::Internet v2.05
X-Submission-Address: std-cpp-submit@vandevoorde.com
Cancel-Lock: sha1:QdTJy8/h7z7A91PKeJzE3R4DofY=
X-Original-Date: Fri, 27 Apr 2012 20:38:34 +0200
Content-Type: text/plain; charset=ISO-8859-1; format=flowed

Am 27.04.2012 20:12, schrieb Jason McKesson:
>  Does the C++11 specification allow you to say that the `make_shared`
>  template is a friend, and thus guarantee that it can access the
>  appropriate private constructors of a class? Yes, there is syntax that
>  would make `make_shared` a friend. But does the spec *require* that
>  the constructors are called directly from `make_shared` itself, since
>  it cannot transfer friendship to any subsidiary object types?

I cannot read anything from this from the specification. To the
contrary, there is a general requirement:

"The expression ::new (pv) T(std::forward<Args>(args)...), where pv has
type void* and points to storage suitable to hold an object of type T,
shall be well formed"

and there is nothing in the wording that allows to conclude that this
requirement is context-based. Requirements in the standard are general
context-free (The standard does not say so explicitly, but the lack of
such guarantee gives evidence for this interpretation). The wording form
used in [structure.requirements] p4

"Requirements are stated in terms of well-defined expressions that
define valid terms of the types that satisfy the requirements."

and p6:

"In some cases the semantic requirements are presented as C++ code. Such
code is intended as a specification of equivalence of a construct to
another construct, not necessarily as the way the construct must be
implemented."

clearly indicates that implementations can use indirection techniques,
so I would strongly discourage any assumption that friendship dedication
to library components could be done portably.

Further, there is some rewording intended due to

http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#2070

This rewording effectively makes the semantics more general and more
indirect again.

The only chance I see for you is to use std::allocate_shared with a
user-provided allocator where you have assigned friendship to the
construct function (I guess that one is of interest for you?) of the
allocator.

If that does not work for you: What kind of problem are you trying to solve?

HTH&  Greetings from Bremen,

Daniel Kr�gler



-- 
[ comp.std.c++ is moderated.  To submit articles, try posting with your ]
[ newsreader.  If that fails, use mailto:std-cpp-submit@vandevoorde.com ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html                      ]


