[snip]
> holder h;
> new (h.storage) Foo;
What is the meaning of that syntax?
>...
> T* u = dangerous_cast(h.storage); // can't do this with
reinterpret_cast
Why would you want to do that in the first place.
>
> HTH,
> --
>David Abrahams
>[EMAIL PROTECTED] * htt
"Gabriel Dos Reis" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> "David B. Held" <[EMAIL PROTECTED]> writes:
>
> | Does this have any merit whatsoever?
> |
> | template
> | T* dangerous_cast(U* p)
> | {
> | return static_cast(static_cast(p));
> | }
>
> Is
"Eric Woodruff" <[EMAIL PROTECTED]> wrote in message
aslbsn$nt3$[EMAIL PROTECTED]">news:aslbsn$nt3$[EMAIL PROTECTED]...
> [snip]
>
> > holder h;
> > new (h.storage) Foo;
>
> What is the meaning of that syntax?
This is placement new syntax. It means construct a Foo at the address
h.storage, withou
"David B. Held" <[EMAIL PROTECTED]> wrote in message
aslftb$cr2$[EMAIL PROTECTED]">news:aslftb$cr2$[EMAIL PROTECTED]...
> "Eric Woodruff" <[EMAIL PROTECTED]> wrote in message
> aslbsn$nt3$[EMAIL PROTECTED]">news:aslbsn$nt3$[EMAIL PROTECTED]...
> > [snip]
> >
> > > holder h;
> > > new (h.storage) F
"Eric Woodruff" <[EMAIL PROTECTED]> wrote in message
asli92$oqn$[EMAIL PROTECTED]">news:asli92$oqn$[EMAIL PROTECTED]...
> [...]
> > > > holder h;
> > > > new (h.storage) Foo;
> [...]
> So the type really is of Foo,
> [...]
No, the type really is char[sizeof(T)] converted to char* const. Since the
"Gabriel Dos Reis" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> David Abrahams <[EMAIL PROTECTED]> writes:
>
> | [...]
> | if is_pointer and is_pointer
> | return (dest_type)(
> | (unisgned)src
> | ^ sizeof
"Gabriel Dos Reis" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> [...]
> What do mean exactly by a "valid Foo*"?
Hmm...I think 5.2.10/7 is more relevant. I guess it depends on what
"unspecified" means. I assumed that it meant that you have a Foo*,
but it mig
(inline)
"Anthony Williams" <[EMAIL PROTECTED]> wrote in
message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
[snip]
> Gabriel Dos Reis writes:
> unsigned char* has _additional_ properties to void* --- you can access the
> object representation of _any_ object through an unsigned char* (and for
P
Eric Woodruff writes:
> "Anthony Williams" <[EMAIL PROTECTED]> wrote in
> message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> > Thus, given that h.storage is properly aligned, (which is the purpose of
> the
> > other union member), after "new(h.storage) Foo", h.storage contains a Foo
> > o
"Anthony Williams" <[EMAIL PROTECTED]> wrote in
message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> Eric Woodruff writes:
> > "Anthony Williams" <[EMAIL PROTECTED]> wrote in
> > message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> > > Thus, given that h.storage is properly aligned, (which
On 07 Dec 2002 12:26:35 +0100, Gabriel Dos Reis
<[EMAIL PROTECTED]> wrote:
>5.2.10/1:
> The result of the expression reinterpret_cast(v) is the result of
> converting the expression v to type T. [...]
Are you saying you really understand what that phrase means? Can you
explain it, and say plea
On Sat, 07 Dec 2002 17:16:42 +0100, Gennaro Prota
<[EMAIL PROTECTED]> wrote:
>On 07 Dec 2002 12:26:35 +0100, Gabriel Dos Reis
><[EMAIL PROTECTED]> wrote:
>
>
>>5.2.10/1:
>> The result of the expression reinterpret_cast(v) is the result of
>> converting the expression v to type T. [...]
>
>Are yo
On 07 Dec 2002 21:16:49 +0100, Gabriel Dos Reis
<[EMAIL PROTECTED]> wrote:
>Do you mean it is invalid to reinterpret_cast<> to void*?
Well, I'm not sure.
5.2.10/7: "A pointer to an object can be explicitly converted to
a pointer to an object of different type.65) Except that converting
an rva
On 08 Dec 2002 15:09:32 +0100, Gabriel Dos Reis
<[EMAIL PROTECTED]> wrote:
>Gennaro Prota <[EMAIL PROTECTED]> writes:
>
>[...]
>
>| If void* is not a "pointer to an object" then reinterpret_cast
>| is invalid. Otherwise it just yields an undefined result.
I should have said "unspecified", sorry.
--- Gabriel Dos Reis <[EMAIL PROTECTED]> wrote:
> I'm not saying I hold the truth. I'm offering my reading, just as others
> are doing.
Yeah, that's ok. I meant: it's unlikely that we can really find a
quote from the standard that says the last word here. Maybe the intent
was to make reinterpre
On Sun, 08 Dec 2002 13:16:24 -0700, Greg Colvin
<[EMAIL PROTECTED]> wrote:
>It may be time to post a question to [EMAIL PROTECTED]
Thank you very much. What is that? An internal list for the C++
committee? Is it open to everybody, or you meant that *you* are going
to post a question there?
Genny
Gennaro Prota writes:
> On 08 Dec 2002 15:09:32 +0100, Gabriel Dos Reis
> <[EMAIL PROTECTED]> wrote:
>
> >Gennaro Prota <[EMAIL PROTECTED]> writes:
> >
> >[...]
> >
> >| If void* is not a "pointer to an object" then reinterpret_cast
> >| is invalid. Otherwise it just yields an undefined r
"Eric Woodruff" <[EMAIL PROTECTED]> writes:
| [snip]
|
| > holder h;
| > new (h.storage) Foo;
|
| What is the meaning of that syntax?
placement-new: Construct a Foo at h.storage.
-- Gaby
___
Unsubscribe & other changes: http://lists.boost.org/mailma
"David B. Held" <[EMAIL PROTECTED]> writes:
| Because you want to get at the T in h in a portable way. Which brings
| me to my next point. Since it seems this is the only context in which this
| cast is guaranteed to give a meaningful result, maybe it should be called
| placement_cast<>?
But th
"Eric Woodruff" <[EMAIL PROTECTED]> writes:
> "David B. Held" <[EMAIL PROTECTED]> wrote in message
> aslftb$cr2$[EMAIL PROTECTED]">news:aslftb$cr2$[EMAIL PROTECTED]...
>> "Eric Woodruff" <[EMAIL PROTECTED]> wrote in message
>> aslbsn$nt3$[EMAIL PROTECTED]">news:aslbsn$nt3$[EMAIL PROTECTED]...
>> >
"David B. Held" <[EMAIL PROTECTED]> writes:
| "Eric Woodruff" <[EMAIL PROTECTED]> wrote in message
| asli92$oqn$[EMAIL PROTECTED]">news:asli92$oqn$[EMAIL PROTECTED]...
| > [...]
| > > > > holder h;
| > > > > new (h.storage) Foo;
| > [...]
| > So the type really is of Foo,
| > [...]
|
| No, the ty
David Abrahams <[EMAIL PROTECTED]> writes:
| "Eric Woodruff" <[EMAIL PROTECTED]> writes:
|
| > "David B. Held" <[EMAIL PROTECTED]> wrote in message
| > aslftb$cr2$[EMAIL PROTECTED]">news:aslftb$cr2$[EMAIL PROTECTED]...
| >> "Eric Woodruff" <[EMAIL PROTECTED]> wrote in message
| >> aslbsn$nt3$[EMA
Gabriel Dos Reis <[EMAIL PROTECTED]> writes:
> David Abrahams <[EMAIL PROTECTED]> writes:
>
> | "Eric Woodruff" <[EMAIL PROTECTED]> writes:
> |
> | > "David B. Held" <[EMAIL PROTECTED]> wrote in message
> | > aslftb$cr2$[EMAIL PROTECTED]">news:aslftb$cr2$[EMAIL PROTECTED]...
> | >> "Eric Woodruff
"David B. Held" <[EMAIL PROTECTED]> writes:
| "Gabriel Dos Reis" <[EMAIL PROTECTED]> wrote in message
| [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
| > [...]
| > What do mean exactly by a "valid Foo*"?
|
| Hmm...I think 5.2.10/7 is more relevant. I guess it depends on what
| "unspecified" means
David Abrahams <[EMAIL PROTECTED]> writes:
| Gabriel Dos Reis <[EMAIL PROTECTED]> writes:
|
| > David Abrahams <[EMAIL PROTECTED]> writes:
| >
| > | "Eric Woodruff" <[EMAIL PROTECTED]> writes:
| > |
| > | > "David B. Held" <[EMAIL PROTECTED]> wrote in message
| > | > aslftb$cr2$[EMAIL PROTECTED]
"David B. Held" <[EMAIL PROTECTED]> writes:
| "Gabriel Dos Reis" <[EMAIL PROTECTED]> wrote in message
| [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
| > David Abrahams <[EMAIL PROTECTED]> writes:
| >
| > | [...]
| > | if is_pointer and is_pointer
| > | return (dest_type)(
| > |
Gabriel Dos Reis <[EMAIL PROTECTED]> writes:
> Thanks for your patience.
>
> Now, imagine an implementation where the original type is remembered,
> then dereferencing the pointer obtained from
>
>char* -> void* -> T*
>
> may just eject you into the outer space.
Is remembering the original ty
David Abrahams <[EMAIL PROTECTED]> writes:
| Gabriel Dos Reis <[EMAIL PROTECTED]> writes:
|
| > Thanks for your patience.
| >
| > Now, imagine an implementation where the original type is remembered,
| > then dereferencing the pointer obtained from
| >
| >char* -> void* -> T*
| >
| > may just
"Eric Woodruff" <[EMAIL PROTECTED]> writes:
[...]
| > Thus, given that h.storage is properly aligned, (which is the purpose of
| the
| > other union member), after "new(h.storage) Foo", h.storage contains a Foo
| > object. Thus accessing it through a pointer-to-Foo is legal, as Foo is the
| > dyn
Gennaro Prota <[EMAIL PROTECTED]> writes:
[...]
| Well, in fact those subsequent paragraphs intentionally give very few
| guarantee, and reinterpret_cast is exactly one of the cases
| which are left unspecified (the guarantee of 5.2.10/7 concerns casting
| to pointers to *object types*). So I gue
--- Gabriel Dos Reis <[EMAIL PROTECTED]> wrote:
> Gennaro Prota <[EMAIL PROTECTED]> writes:
>
> [...]
>
> | Well, in fact those subsequent paragraphs intentionally give very few
> | guarantee, and reinterpret_cast is exactly one of the cases
> | which are left unspecified (the guarantee of 5.2.1
Gennaro Prota <[EMAIL PROTECTED]> writes:
| --- Gabriel Dos Reis <[EMAIL PROTECTED]> wrote:
| > Gennaro Prota <[EMAIL PROTECTED]> writes:
| >
| > [...]
| >
| > | Well, in fact those subsequent paragraphs intentionally give very few
| > | guarantee, and reinterpret_cast is exactly one of the case
Gennaro Prota <[EMAIL PROTECTED]> writes:
[...]
| If void* is not a "pointer to an object" then reinterpret_cast
| is invalid. Otherwise it just yields an undefined result. I haven't
| found a definition of "pointer to object" in the standard; anyhow
| certainly void is not an object type.
void*
Gennaro Prota <[EMAIL PROTECTED]> writes:
[...]
| > I haven't
| >| found a definition of "pointer to object" in the standard; anyhow
| >| certainly void is not an object type.
| >
| >void* is the generic type of "pointer to object."
|
| Well, as I said I don't find any definition of the expressi
Gennaro Prota <[EMAIL PROTECTED]> writes:
[...]
| > | In any case, do you agree that at least the
| > | result is unspecified?
| >
| > I don't think I agree with this part; at least if it means anything
| > other that converting a Foo* to void*.
|
| Well, then I don't think we can establish "th
It may be time to post a question to [EMAIL PROTECTED]
At 12:59 PM 12/8/2002, you wrote:
>--- Gabriel Dos Reis <[EMAIL PROTECTED]> wrote:
>
>> I'm not saying I hold the truth. I'm offering my reading, just as others
>> are doing.
>
>Yeah, that's ok. I meant: it's unlikely that we can really find
I'll raise the issue the committee reflector.
Gennaro Prota <[EMAIL PROTECTED]> writes:
[...]
| > | char * p = ...
| > | reinterpret_cast(p)
| > |
| > | is illegal, because the sentence above talks about conversion to *a
| > | different* type. And the conversions that are not listed cannot
At 03:53 PM 12/8/2002, Gennaro Prota wrote:
>On Sun, 08 Dec 2002 13:16:24 -0700, Greg Colvin
><[EMAIL PROTECTED]> wrote:
>
>>It may be time to post a question to [EMAIL PROTECTED]
>
>Thank you very much. What is that? An internal list for the C++
>committee? Is it open to everybody, or you meant t
At 02:58 PM 12/9/2002, you wrote:
>At 03:53 PM 12/8/2002, Gennaro Prota wrote:
>
>>On Sun, 08 Dec 2002 13:16:24 -0700, Greg Colvin
>><[EMAIL PROTECTED]> wrote:
>>
>>>It may be time to post a question to [EMAIL PROTECTED]
>>
>>Thank you very much. What is that? An internal list for the C++
>>committ
39 matches
Mail list logo