小编dCu*_*lic的帖子

Xcode 10调用不可用的函数std :: visit

使用Xcode 10 GM编译以下程序时:

#include <iostream>
#include <string>
#include <variant>

void hello(int) {
    std::cout << "hello, int" << std::endl;
}

void hello(std::string const & msg) {
    std::cout << "hello, " << msg << std::endl;
}

int main(int argc, const char * argv[]) {
    // insert code here...
    std::variant< int, std::string > var;

    std::visit
    (
        []( auto parameter )
        {
            hello( parameter );
        },
        var
     );

    return 0;
}
Run Code Online (Sandbox Code Playgroud)

我收到以下错误:

main.cpp:27:5:调用不可用的函数'visit':在macOS 10.14中引入

但是,如果我将最小部署目标更改为macOS 10.14,则代码​​编译正常并且可以正常运行,即使我正在运行macOS 10.13.

由于std::visit是功能模板,并且不应该依赖于操作系统版本(我通过在较低版本的mac上运行代码而不是实际支持的证明),这应该被视为错误并报告给Apple还是这种预期的行为?

编译iOS时会出现同样的情况(iOS 12是最低限度的预期).

c++ xcode ios c++17

17
推荐指数
2
解决办法
2749
查看次数

WICConvertBitmapSource BGR 到 Gray 意外像素格式转换

我正在使用WICConvertBitmapSource函数将像素格式从 BGR 转换为灰色,但我得到了意外的像素值。

...

pIDecoder->GetFrame( 0, &pIDecoderFrame ); 

pIDecoderFrame->GetPixelFormat( &pixelFormat ); // GUID_WICPixelFormat24bppBGR

IWICBitmapSource * dst;
WICConvertBitmapSource( GUID_WICPixelFormat8bppGray, pIDecoderFrame, &dst );
Run Code Online (Sandbox Code Playgroud)

具有以下 BGR 像素值的 4x3 图像示例:

[  0,   0, 255,   0, 255,   0, 255,   0,   0;
   0, 255, 255, 255, 255,   0, 255,   0, 255;
   0,   0,   0, 119, 119, 119, 255, 255, 255;
 233, 178,  73, 233, 178,  73, 233, 178,  73]
Run Code Online (Sandbox Code Playgroud)

我得到的灰色像素值:

[127, 220,  76;
 247, 230, 145;
   0, 119, 255;
 168, 168, 168]
Run Code Online (Sandbox Code Playgroud)

我期望得到的灰色像素值(ITU-R …

c++ windows imaging image-processing color-space

10
推荐指数
1
解决办法
133
查看次数

标签 统计

c++ ×2

c++17 ×1

color-space ×1

image-processing ×1

imaging ×1

ios ×1

windows ×1

xcode ×1