I have written this test code:
int main(int argc, const char * argv[]) {
int *testRaw = nullptr;
cout << sizeof(testRaw) << endl;
unique_ptr<int> testUnique(nullptr);
cout << sizeof(testUnique) << endl;
auto CustomeDeleter = [](int *ptr)
{
cout << *ptr;
delete ptr;
};
unique_ptr<int, decltype(CustomeDeleter)> testUniqueCustom(nullptr, CustomeDeleter);
cout << sizeof(testUniqueCustom) << endl;
return 0;
}
With the compiler clang-700.1.81 my output is:
8
8
8
How could it be that the custom deleter didn't increase the pointer size? As I understand lambda function is an object of the closure type, and the size of any class always > 0 in C++. Thank you for your help!