std::unique_ptr and pointer to pointer

前端 未结 2 1333
悲&欢浪女
悲&欢浪女 2021-01-18 07:46

I want to use std::unique_ptr in combination with FreeImage\'s FITAG. The code in plain C would be:

... load image;

FITAG* tag = NULL;
FreeImag         


        
2条回答
  •  感情败类
    2021-01-18 07:49

    Reverse the order of operations; first acquire the resource and then construct the unique_ptr.

    FITAG *p = NULL;
    FreeImage_GetMetadata(FIMD_EXIF_EXIF, bitmap, "Property", &p);
    std::unique_ptr tag(p, &FreeImage_DeleteTag);
    

自定义标题
段落格式
字体
字号
代码语言
提交回复
热议问题