template<typename _Tp1>
operator auto_ptr_ref<_Tp1>() throw()
{ return auto_ptr_ref<_Tp1>(this->release()); }
template<typename _Tp1>
operator auto_ptr<_Tp1>() throw()
{ return auto_ptr<_Tp1>(this->release()); }
I found definition of this two methods in stl class auto_ptr.
Can somebody explain me please, how functions other then constructors have no return type ?
Because they are implicit conversion operators that return auto_ptr_ref<_Tp1>
and auto_ptr<_Tp1>
respectively. These themselves serve as return-type declarations.
Conversion operators to type auto_ptr_ref
and auto_ptr
n3337 12.3.2/1
A member function of a class X having no parameters with a name of the form
conversion-function-id: operator conversion-type-id
conversion-type-id: type-specifier-seq conversion-declaratoropt
conversion-declarator: ptr-operator conversion-declaratoropt
specifies a conversion from X to the type specified by the conversion-type-id .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.