Search code examples
c++templatesstandard-library

A question about auto_ptr


template<class Y>

operator auto_ptr_ref<Y>() throw() {

   return auto_ptr_ref<Y>(release());
}

It is part of implementation of class auto_ptr in standard library.

What does this means to do?

Why there is an "auto_ptr_ref" between "operator" and "()"?


Solution

  • That is the conversion operator in action, casting from auto_ptr to auto_ptr_ref<Y>.