Sometimes I saw this code:
void* Create() { int* t{new int{10}}; return t; } class Deleter {
It does not compile. From VS2013, he says:
error: C2440: 'initializing': cannot convert from 'initializer-list' to 'std :: unique_ptr' Constructor cannot use source type or overload constructor was ambiguous
But if I uncomment the line using pointer = void*; , she works! Also, if I change the alias name to something other than pointer , I get the same error. It seems that having a using directive with the exact name pointer is crucial. But why? I could not find any explanation.
c ++ smart-pointers
nikitablack
source share