I've changed the question title and body see if it suits better :).
I read a member function signature on cppreference: unique_ptr/reset.
void reset( pointer ptr = pointer() ) noexcept;
and pointer
is a member type of unique_ptr
, documented as
pointer
|std::remove_reference<Deleter>::type::pointer
if that type exists, otherwiseT*
. Must satisfyNullablePointer
What I've learnt in the comments:
pointer ptr = pointer()
is somehow equivalent to e.g.int
,using pointer = int*; pointer ptr = pointer()
- And if it's a built-in type like
int
, thenptr
is a zero-initialized variable. I get aint*
pointer with0/NULL/nullptr
here. - There is not a "raw" statement for
using pointer = int*; pointer ptr = pointer()
, which is thatint* ptr = int*()
won't work.
I also read Do built-in types have default constructors? and that helps a lot.
I want to know a bit more about this behaviour(a built-in type can be constructed in a custom class way), if it can be explained in more details:
using pointer = int*; pointer ptr = pointer()
Seriously no "raw" syntax for this statment? I used to think that everything use a typedef
or using
could be written down with a "raw" version. Like a one-to-one mapping.