相关疑难解决方法(0)

std :: unique_ptr和指针指针

我想std::unique_ptr与FreeImage的FITAG结合使用.普通C中的代码是:

... load image;

FITAG* tag = NULL;
FreeImage_GetMetadata(FIMD_EXIF_EXIF, bitmap, "Property", &tag);
... do some stuff with tag;
FreeImage_DeleteTag(tag);

... delete image;
Run Code Online (Sandbox Code Playgroud)

我对unique_ptr的尝试:

std::unique_ptr<FITAG, void(*)(FITAG*)> tag(NULL, &FreeImage_DeleteTag);
FreeImage_GetMetadata(FIMD_EXIF_EXIF, bitmap, "Property", &tag.get());
Run Code Online (Sandbox Code Playgroud)

这明显回归:

cannot take the address of an rvalue of type 'pointer' (aka 'FITAG *')
Run Code Online (Sandbox Code Playgroud)

我该如何解决这个问题?

非常感谢提前.

c++ unique-ptr c++11

5
推荐指数
1
解决办法
1366
查看次数

标签 统计

c++ ×1

c++11 ×1

unique-ptr ×1