Re: [RFC] Implementing addressof for C++0x

2010-05-20 Thread Peter Dimov
Jason Merrill wrote: On 05/20/2010 08:18 AM, Peter Dimov wrote: On 05/20/2010 01:55 PM, Paolo Carlini wrote: It's uglier because the code above doesn't work for functions, By the way, do you have a specific testcase in mind? Because addressof_fn_test.cpp, part of Boost, passes... This is p

Re: [RFC] Implementing addressof for C++0x

2010-05-20 Thread Paolo Carlini
On 05/20/2010 08:13 PM, Jason Merrill wrote: > The standard permits a compiler to accept or reject such a cast. > > 5.2.10/8: Converting a pointer to a function into a pointer to an > object type or vice versa is conditionally-supported. The meaning of > such a conversion is implementation-defined

Re: [RFC] Implementing addressof for C++0x

2010-05-20 Thread Jason Merrill
On 05/20/2010 08:18 AM, Peter Dimov wrote: On 05/20/2010 01:55 PM, Paolo Carlini wrote: It's uglier because the code above doesn't work for functions, By the way, do you have a specific testcase in mind? Because addressof_fn_test.cpp, part of Boost, passes... This is probably a g++/gcc exte

Re: [RFC] Implementing addressof for C++0x

2010-05-20 Thread Andrew Pinski
Sent from my iPhone On May 20, 2010, at 5:43 AM, "Peter Dimov" wrote: Paolo Carlini wrote: On 05/20/2010 02:18 PM, Peter Dimov wrote: On 05/20/2010 01:55 PM, Paolo Carlini wrote: It's uglier because the code above doesn't work for functions, By the way, do you have a specific testcase i

Re: [RFC] Implementing addressof for C++0x

2010-05-20 Thread Peter Dimov
Paolo Carlini wrote: On 05/20/2010 02:18 PM, Peter Dimov wrote: On 05/20/2010 01:55 PM, Paolo Carlini wrote: It's uglier because the code above doesn't work for functions, By the way, do you have a specific testcase in mind? Because addressof_fn_test.cpp, part of Boost, passes... This is p

Re: [RFC] Implementing addressof for C++0x

2010-05-20 Thread Paolo Carlini
On 05/20/2010 02:18 PM, Peter Dimov wrote: >> On 05/20/2010 01:55 PM, Paolo Carlini wrote: >>> It's uglier because the code above doesn't work for functions, >>> >> By the way, do you have a specific testcase in mind? >> >> Because addressof_fn_test.cpp, part of Boost, passes... > > This is probabl

Re: [RFC] Implementing addressof for C++0x

2010-05-20 Thread Peter Dimov
On 05/20/2010 01:55 PM, Paolo Carlini wrote: It's uglier because the code above doesn't work for functions, By the way, do you have a specific testcase in mind? Because addressof_fn_test.cpp, part of Boost, passes... This is probably a g++/gcc extension... some compilers do not allow refere

Re: [RFC] Implementing addressof for C++0x

2010-05-20 Thread Paolo Carlini
On 05/20/2010 01:55 PM, Paolo Carlini wrote: > It's uglier because the code above doesn't work for functions, > By the way, do you have a specific testcase in mind? Because addressof_fn_test.cpp, part of Boost, passes... Paolo.

Re: [RFC] Implementing addressof for C++0x

2010-05-20 Thread Paolo Carlini
Hi, >>> ... for reference, it would be something like this (in my >>> recollections, >>> it was even uglier ;) >>> >>> template >>> _Tp* >>> addressof(_Tp& __v) >>> { >>> return reinterpret_cast<_Tp*> >>> (&const_cast(reinterpret_cast>> char&>(__v))); >>> } > It's uglier because t

Re: [RFC] Implementing addressof for C++0x

2010-05-20 Thread Peter Dimov
On 05/20/2010 01:10 PM, Paolo Carlini wrote: ... for reference, it would be something like this (in my recollections, it was even uglier ;) template _Tp* addressof(_Tp& __v) { return reinterpret_cast<_Tp*> (&const_cast(reinterpret_cast(__v))); } It's uglier because the code a

Re: [RFC] Implementing addressof for C++0x

2010-05-20 Thread Paolo Carlini
On 05/20/2010 01:10 PM, Paolo Carlini wrote: > ... for reference, it would be something like this (in my recollections, > it was even uglier ;) > > template > _Tp* > addressof(_Tp& __v) > { > return reinterpret_cast<_Tp*> > (&const_cast(reinterpret_cast(__v))); > } > By the way

Re: [RFC] Implementing addressof for C++0x

2010-05-20 Thread Paolo Carlini
... for reference, it would be something like this (in my recollections, it was even uglier ;) template _Tp* addressof(_Tp& __v) { return reinterpret_cast<_Tp*> (&const_cast(reinterpret_cast(__v))); } I'm not sure... Paolo.