c++

ambiguous call to overloaded function

百般思念 提交于 2021-02-20 06:44:05
问题 I have two functions: void DoSomething( const tchar* apsValue ) void DoSomething( size_t aiValue ) Now I want to pass '0' as a size_t: DoSomething(0); The compiler throws an error: "ambiguous call to overloaded function" To solve this, I can use static_cast, for instance: DoSomething(static_cast<size_t>(0)); Or simple: DoSomething(size_t(0)); Is one of them better than the other? Are there any other approaches to solve this? 回答1: It's ambiguous because 0 has type int , not size_t . It can

How to fill contours that touch the image border?

本秂侑毒 提交于 2021-02-20 06:35:29
问题 Say I have the following binary image created from the output of cv::watershed() : Now I want to find and fill the contours, so I can separate the corresponding objects from the background in the original image (that was segmented by the watershed function). To segment the image and find the contours I use the code below: cv::Mat bgr = cv::imread("test.png"); // Some function that provides the rough outline for the segmented regions. cv::Mat markers = find_markers(bgr); cv::watershed(bgr,

How to fill contours that touch the image border?

馋奶兔 提交于 2021-02-20 06:34:12
问题 Say I have the following binary image created from the output of cv::watershed() : Now I want to find and fill the contours, so I can separate the corresponding objects from the background in the original image (that was segmented by the watershed function). To segment the image and find the contours I use the code below: cv::Mat bgr = cv::imread("test.png"); // Some function that provides the rough outline for the segmented regions. cv::Mat markers = find_markers(bgr); cv::watershed(bgr,

Namespace alias in c++

二次信任 提交于 2021-02-20 06:26:16
问题 I use c++11 while I need some classes from c++17 library. When using boost from which classes were added I wish to do the following: #if __cplusplus < CPP17 using std::any = boost::any; #endif Such alias is not allowed. Also extending the std namespace causes undefined behaviour. I wish my code to look the same regardles of the c++ version. Is there a clear way? 回答1: The clear way is to add a customized name for it. #if __cplusplus < CPP17 using my_any = boost::any; #else using my_any = std:

Namespace alias in c++

自作多情 提交于 2021-02-20 06:20:06
问题 I use c++11 while I need some classes from c++17 library. When using boost from which classes were added I wish to do the following: #if __cplusplus < CPP17 using std::any = boost::any; #endif Such alias is not allowed. Also extending the std namespace causes undefined behaviour. I wish my code to look the same regardles of the c++ version. Is there a clear way? 回答1: The clear way is to add a customized name for it. #if __cplusplus < CPP17 using my_any = boost::any; #else using my_any = std:

How can I test if all bits are set or all bits are not?

房东的猫 提交于 2021-02-20 06:11:30
问题 Using bitwise operator how can I test if the n least significant bits of an integer are either all sets or all not sets. For example if n = 3 I only care about the 3 least significant bits the test should return true for 0 and 7 and false for all other values between 0 and 7. Of course I could do if x = 0 or x = 7 , but I would prefer something using bitwise operators. Bonus points if the technique can be adapted to take into accounts all the bits defined by a mask. Clarification : If I

flutter: 窗口初始与绘制流程

孤街浪徒 提交于 2021-02-20 05:55:09
环境: flutter sdk v1.7.8+hotfix.3 @stable 对应 flutter engine: 54ad777f 这里关注的是C++层面的绘制流程,平台怎样驱动和响应绘制与渲染的过程,并不是Dart部分的渲染。 结合之前的分析,在虚拟机实例的构造函数中调用了一个重要方法 DartUI::InitForGlobal() , 调用流程再罗列一下: DartVMRef::Create DartVMRef::DartVMRef DartVM::Create DartVMData::Create DartVM::DartVM DartUI::InitForGlobal() 实现体很明了,注册了各种类对象的方法,也就是说,这些在dart语言继承 NativeFieldWrapperClass2 的类都有一份在C++层的实现,也说明了DartSDK是如何提供接口绑定与C++层的实现,相当于java语言中的jni。 另外还有针对 Isolate 的初始化,不过只是设置了一个可以import的路径,并不重要: DartIsolate::CreateRootIsolate DartIsolate::CreateDartVMAndEmbedderObjectPair DartIsolate::LoadLibraries DartUI::InitForIsolate Dart

C++简单程序设计

╄→尐↘猪︶ㄣ 提交于 2021-02-20 05:54:17
计算机的最基本功能是数据处理 l C++支持的基本数据类型: n 整数、实数、字符、布尔数据 l C++支持的基本运算 n 算术运算、关系运算、逻辑运算、位运算、逗号运算、条件运算 程序要能够输入数据、输出数据 l C++中的数据输入/输出可以调用预定义的功能模块实现 程序的执行流程 l 顺序的,因此程序要能够对执行流程进行选择(选择、开关语句); l 反复用同一算法依次处理大批量数据(循环语句)。 枚举类型 l 通过列出所有可取值来定义一种新类型。 C++的特点和程序实例 C++的产生和发展 l 从C语言发展演变而来,最初被称为"带类的C"; l 1983年正式取名为C++; l 1998年11月被国际标准化组织(ISO)批准为国际标准; l 2003年10月15日发布第2版C++标准ISO/IEC 14882:2003; l 2011年8月12日ISO公布了第三版C++标准C++11,包含核心语言的新机能、扩展C++标准程序库。 l 2014年8月18日ISO公布了C++14,其正式名称为"International Standard ISO/IEC 14882:2014(E) Programming Language C++"。 l C++14作为C++11的一个小扩展,主要提供漏洞修复和小的改进。 C++的特点 l 兼容C,支持面向过程的程序设计; l 支持面向对象的方法;

Internal compiler error : segmentation fault with g++4.3.5

强颜欢笑 提交于 2021-02-20 05:39:04
问题 Here is the code //fail_.cpp template< unsigned char X, class L> class A { public: typedef void (A::*fptr)(); class B { public: B(typename A< X, L> ::fptr ); }; }; template < unsigned char X, typename L > A<X,L>::B::B ( fptr ) { } g++ -c fail_.cpp gives fail_.cpp:11: internal compiler error: Segmentation fault Please submit a full bug report, with preprocessed source if appropriate. See < file:///usr/share/doc/gcc-4.3/README.Bugs > for instructions. Looks like a bug to me in g++4.3.5, g++4.4

How to detect Blur rate of a face effectively in c++?

风格不统一 提交于 2021-02-20 05:24:23
问题 I am trying to detect blur rate of the face images with below code. cv::Mat greyMat; cv::Mat laplacianImage; cv::Mat imageClone = LapMat.clone(); cv::resize(imageClone, imageClone, cv::Size(150, 150), 0, 0, cv::INTER_CUBIC); cv::cvtColor(imageClone, greyMat, CV_BGR2GRAY); Laplacian(greyMat, laplacianImage, CV_64F); cv::Scalar mean, stddev; // 0:1st channel, 1:2nd channel and 2:3rd channel meanStdDev(laplacianImage, mean, stddev, cv::Mat()); double variance = stddev.val[0] * stddev.val[0]; cv: