[assign] ptr_list_of legal?

Hi, I found a snippet from <boost/assign/ptr_list_of.hpp>: template< class T > class generic_ptr_list { // ... public: template< class PtrContainer > operator std::auto_ptr<PtrContainer>() const { .. } }; IIRC, this automatic conversion doesn't work on any conforming compiler. The right way seems to make lvalue: 'operator std::auto_ptr<PtrContainer> & () const'. Regards, -- Shunsuke Sogame

shunsuke skrev:
Hi,
I found a snippet from <boost/assign/ptr_list_of.hpp>:
template< class T > class generic_ptr_list { // ... public: template< class PtrContainer > operator std::auto_ptr<PtrContainer>() const { .. } };
IIRC, this automatic conversion doesn't work on any conforming compiler.
Why? -Thorsten

Thorsten Ottosen wrote:
shunsuke skrev:
Hi,
I found a snippet from <boost/assign/ptr_list_of.hpp>:
template< class T > class generic_ptr_list { // ... public: template< class PtrContainer > operator std::auto_ptr<PtrContainer>() const { .. } };
IIRC, this automatic conversion doesn't work on any conforming compiler.
Why?
The rule seems complicated. :-( This is because it requires two user-defined conversions? generic_ptr_list -> operator auto_ptr() -> operator auto_ptr_ref() -> auto_ptr In the case of lvalue: generic_ptr_list -> operator auto_ptr&() -> auto_ptr I hope a lawyer will look into this posting. :-) Regards, -- Shunsuke Sogame

shunsuke skrev:
Thorsten Ottosen wrote:
shunsuke skrev:
Hi,
I found a snippet from <boost/assign/ptr_list_of.hpp>:
template< class T > class generic_ptr_list { // ... public: template< class PtrContainer > operator std::auto_ptr<PtrContainer>() const { .. } };
IIRC, this automatic conversion doesn't work on any conforming compiler. Why?
The rule seems complicated. :-( This is because it requires two user-defined conversions? generic_ptr_list -> operator auto_ptr() -> operator auto_ptr_ref() -> auto_ptr
In the case of lvalue: generic_ptr_list -> operator auto_ptr&() -> auto_ptr
I hope a lawyer will look into this posting. :-)
ME to. It's no secret that some compilers had problems with it, but if IIRC, comeau could do it. -Thorsten

Thorsten Ottosen wrote:
The rule seems complicated. :-( This is because it requires two user-defined conversions? generic_ptr_list -> operator auto_ptr() -> operator auto_ptr_ref() -> auto_ptr
In the case of lvalue: generic_ptr_list -> operator auto_ptr&() -> auto_ptr
I hope a lawyer will look into this posting. :-)
ME to.
It's no secret that some compilers had problems with it, but if IIRC, comeau could do it.
I tried to compile this: #include <memory> // auto_ptr struct List { template< class X > operator std::auto_ptr<X>() const; }; int main() { std::auto_ptr<int> a = List(); } msvc7.1, msvc8, gcc3.4, gcc4.1 and comeau-online all fails to compile. Regards, -- Shunsuke Sogame
participants (2)
-
shunsuke
-
Thorsten Ottosen