이 문제는 Objective-C (++)의 제한과 C++와의 상호 작용을 오해 한 직접적인 결과 일 수 있습니다. 아니면 나 앞에서 무언가를 놓치고있는 경우일지도 모른다.iOS - GCC가 명백하게 보이는 함수를 보지 못했습니다.
나는 Objective-C++에서 배후에서 작동하는 C++ 클래스를 사용합니다. 따라서 템플릿 기반 함수를 호출하는 C++ 클래스 템플릿이 있습니다. 그런 다음 UIImage를 만들기 위해 템플릿 기능을 전문화했습니다.
그러나 빌드 할 때 다음 오류가 발생합니다.
../ImageProcessing/ImageProcessing/MacOS/MacOSImage.h:43: error: no matching function for call to 'MacOSImage<R5G5B5A1>::MakeUIImage(std::vector<R5G5B5A1, std::allocator<R5G5B5A1> >&, unsigned int, unsigned int)'
../ImageProcessing/ImageProcessing/MacOS/MacOSImage.h:41: note: candidates are: UIImage* MacOSImage<ColourSpace>::MakeUIImage() [with ColourSpace = R5G5B5A1]
내 헤더 파일은 다음과 같다 :이 오류가 오히려 혼란을 찾을
#ifndef ImageProcessing_MacOSImage_h
#define ImageProcessing_MacOSImage_h
#include "Image.h"
#ifdef __OBJC__
#import <UIKit/UIImage.h>
#else
typedef void UIImage;
#endif
template< typename ColourSpace > UIImage* MakeUIImage(const std::vector<ColourSpace>& colours, unsigned int width, unsigned int height)
{
return NULL;
}
template< typename ColourSpace > class MacOSImage : public BaseImage<ColourSpace>
{
protected:
public:
MacOSImage(unsigned int width, unsigned int height);
virtual ~MacOSImage() {};
UIImage* MakeUIImage();
};
template< typename ColourSpace > inline MacOSImage<ColourSpace>::MacOSImage(unsigned int width, unsigned int height) :
BaseImage<ColourSpace>(width, height)
{
}
template< typename ColourSpace > inline UIImage* MacOSImage<ColourSpace>::MakeUIImage()
{
return MakeUIImage(BaseImage<ColourSpace>::Pixels(), BaseImage<ColourSpace>::GetWidth(), BaseImage<ColourSpace>::GetHeight());
}
#endif
. 무엇보다도 내 전문 분야를 무시하면 파일의 맨 위에있는 프로토 타입과 정확하게 일치해야하는 템플릿 기능이 있기 때문입니다. 유일한 단점은 NULL을 반환한다는 것입니다. 그러나 이것은 내가 컴파일 할 수 있다면 계속 진행되고있는 것에 대한 아이디어를 나에게 줄 것이다.
그렇다면 컴파일되지 않는 이유는 누구나 알 수 있습니까?
건배!
편집 : 여기에 요청이므로 image.h의 :
#ifndef ImageProcessing_Image_h
#define ImageProcessing_Image_h
#include <vector>
template< typename ColourSpace > class BaseImage
{
protected:
unsigned int mWidth;
unsigned int mHeight;
std::vector<ColourSpace> mPixels;
public:
BaseImage(unsigned int width, unsigned int height);
virtual ~BaseImage() {};
std::vector<ColourSpace>& Pixels();
const std::vector<ColourSpace>& Pixels() const;
unsigned int GetWidth() const { return mWidth; }
unsigned int GetHeight() const { return mHeight; }
unsigned int GetBytesPerPixel() const { return sizeof(ColourSpace); }
unsigned int GetBitsPerPixel() const { return GetBytesPerPixel() * 8; }
};
template< typename ColourSpace > inline BaseImage<ColourSpace>::BaseImage(unsigned int width, unsigned int height) :
mWidth(width),
mHeight(height),
mPixels(width * height)
{
}
template< typename ColourSpace > inline std::vector<ColourSpace>& BaseImage<ColourSpace>::Pixels()
{
return mPixels;
}
template< typename ColourSpace > inline const std::vector<ColourSpace>& BaseImage<ColourSpace>::Pixels() const
{
return mPixels;
}
#if defined(_OSX)
#include "MacOS/MacOSImage.h"
#define Image MacOSImage
#elif defined(_WIN32)
#include "Win32/Win32Image.h"
typedef Win32Image Image;
#else
#error We need a platform specific implementation of the image class
#endif
#endif
'allocator'(두 번째 인수)에서 컴파일 오류가 발생하는 반면 – fazo
은 std :: vector의 std :: allocator가 기본값으로 초기화되어 해당 AFAIK를 무시할 수 있습니다! – Goz
Image.h의 관련 부분을 붙여주십시오. – Perception