에도 명시 적으로 함수 포인터의 매개 변수가 const를 것을 언급함으로써, 이러한 유형의 기능을 변환 할 수하지 않는 것 :const 매개 변수가있는 함수를 함수 포인터로 변환 할 수 없습니까?
#include <iostream>
template <typename T>
class Image{};
template <typename TPixel>
static void
FillImage(const Image<TPixel>* const image){}
//FillImage(Image<TPixel>* const image){} // Replacing the above line with this one compiles fine
int main()
{
typedef Image<float> ImageType;
ImageType* image = new ImageType;
void (*autoFunctionPointer)(const decltype(image)) = FillImage;
autoFunctionPointer(image);
}
사람이 그 변환을 수행하는 방법을 설명 할 수 있습니까?
는, 현재 매개 변수에 imagetype * const''로 확장합니다. 'decltype'을 통해 쉽게 이해할 수 없습니다. – Xeo
어쨌든 C++ 11을 사용한다면 왜'auto'가 아닌가? – leftaroundabout
@leftaroundabout - 내가 사용하고자하는 오버로드를 지정해야합니다 (http://stackoverflow.com/questions/13632507/how-to-get-a-function-pointer-to-the-overloaded-function-that 참조 자세한 것은 compiler-choos를 참조하십시오). –