Say I have two classes:
\"Foo.h\"
#pragma once
class Foo
{
public:
Foo()
{
};
~Foo()
{
};
};
\"A.h\"
The constructor needs access to the deleter in just the same way the destructor does: exception safety requires that the constructor be able to roll-back initialisation of all the members in the case that your constructor's body throws:
[C++14: 12.6.2/10]:
In a non-delegating constructor, the destructor for each potentially constructed subobject of class type is potentially invoked (12.4). [ Note: This provision ensures that destructors can be called for fully-constructed sub-objects in case an exception is thrown (15.2). —end note ]
Related:
It is no possible for 'A' to not have a constructor.
If you comment the constructor you wrote, the compiler will make a default constructor for you and it won't necessarily be in the same place you defined the one you made. Causing said problem.