I want to do something like this:
SomeType *y; /* ... snip ... */ auto x = new decltype(y); // Create a new pointer "x" to a SomeType object.
But decltype(y) is SomeType* , and decltype(*y) is SomeType& . Is there a way to get a simple SomeType from y ?
decltype(y)
SomeType*
decltype(*y)
SomeType&
SomeType
y
Since decltype(*y) is a link, you can use std::remove_reference :
std::remove_reference
new std::remove_reference<decltype(*y)>::type;