Reputation: 1510
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 ?
Upvotes: 2
Views: 171
Reputation:
Because they are implicit conversion operators that return auto_ptr_ref<_Tp1>
and auto_ptr<_Tp1>
respectively. These themselves serve as return-type declarations.
Upvotes: 6
Reputation: 55887
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.
Upvotes: 2