The pointer refers to const .
So const decltype(image) equivalent to ImageType* const , not const ImageType*
If you change image to
const ImageType* image = new ImageType;
The first version of FillImage() works as expected.
To get const ImageType* , you can use std :: remove_pointer
#include <type_traits> ... void (*autoFunctionPointer)(const std::remove_pointer<decltype(image)>::type *) = FillImage;
source share