
On Fri, Dec 18, 2009 at 9:19 PM, Emil Dotchevski <emildotchevski@gmail.com> wrote:
On Fri, Dec 18, 2009 at 11:07 AM, Felipe Magno de Almeida <felipe.m.almeida@gmail.com> wrote:
On Fri, Dec 18, 2009 at 4:57 PM, Emil Dotchevski <emildotchevski@gmail.com> wrote:
On Fri, Dec 18, 2009 at 5:46 AM, Felipe Magno de Almeida <felipe.m.almeida@gmail.com> wrote:
[snip]
But nothing else is guaranteed. The compiler might very well increment it by one byte when casting to T2 and then decrement it when casting it back. It is perfectly valid behavior for reinterpret_cast.
It is perfectly portable as well.
It is not portable if we dereference it, which optional does.
I am going off of what Giovanni said earlier in this thread about how optional works, which seems to contradict your statement above.
Just to clarify, my comment was only about aliasing issues, i.e. in my opinion boost.optional has none. I didn't comment on boost.optional usage of reinterpret_cast. That's a completely orthogonal issue (FWIW, I think that static_cast is theoretically better, but in practice I do not think that it would make any difference with any existing compiler) -- gpd