草庐IT

no-match

全部标签

c++ - boost .python : Argument types did not match C++ signature

我在python中调用C++函数时遇到一个奇怪的问题。我公开了一个我想从中调用函数的类:class_>("MyClass",init())//....def("someFunc",&MyClass::someFunc);我得到一个std::shared_ptr来自另一个类的成员变量,该类通过.def_readonly(...)公开当我尝试调用该函数时,出现以下错误:File"pytest.py",line27,intest_funccu.someFunc("string")Boost.Python.ArgumentError:PythonargumenttypesinMyClass.s

c++ - "No viable overloaded ' = ' "为什么?

我正在为我的一门类(class)做一个项目,我很确定我几乎完成了这个项目。基本上我必须输入2人的票,我必须找到最高价和最低价。我需要重载*和/运算符来解决该项目的问题。此外,根据老师的指示,friend声明对于该项目来说是必需的。现在,对于这个问题。我正在尝试将正确的票证变量(t1或t2)存储到t3中,以便我可以将其返回给主变量。当我使用“=”将t1设置为t3时,它说“没有可行的重载'='”。以下是我的代码:#includeusingnamespacestd;classticket{public:ticket();doubleinput();doubleoutput();friendt

c++ - 在 R 中使用 C++ 编译错误 : "RcppArmadillo.h: No such file or directory"

$exportPKG_CPPFLAGS=`Rscript-e'Rcpp:::CxxFlags()'`$exportPKG_LIBS=`Rscript-e'Rcpp:::LdFlags()'`$RCMDSHLIBmy.cppg++-I/usr/share/R/include-DNDEBUG-I/usr/local/lib/R/site-library/Rcpp/include-fpic-g-O2-fstack-protector--param=ssp-buffer-size=4-Wformat-Wformat-security-Werror=format-security-D_FORTI

Visual Studio 2022: fatal error C1083: 无法打开包括文件: “crtdbg.h”: No such file or directory

1、报错内容fatal errorC1083:无法打开包括文件:“crtdbg.h”:Nosuchfileordirectory出现这个的主要原因是安装WindowsSDK时版本出错,需要根据自己的windows版本选择安装对应版本的WindowsSDKVS2022包括的版本如下:Windows版本WindowsSDK版本Windows10版本1903Windows10SDK版本1903(10.0.18362.1)Windows10版本2004Windows10SDK版本2004(10.0.19041.0)Windows10版本21H2Windows10SDK版本2104(10.0.20348

C++ 设计 : cast from base to derived class with no extra data members

我编写了很多处理消息协议(protocol)的代码。消息协议(protocol)通常会有一个通用的消息帧,可以从串行端口或套接字反序列化;该帧包含消息类型,消息负载必须根据消息类型进行处理。通常我会编写一组多态类,其中包含访问器方法和一个引用消息框架的构造函数。我突然想到,我可以直接从消息帧派生访问器类,然后从消息帧重新解释_cast到适当的访问器类,而不是根据对消息帧的引用构造访问器类。这使代码更加简洁并节省了一些字节和处理器周期。请参阅下面的(极其人为和浓缩的)示例。显然,对于生产代码,这一切都需要适当封装,转换成为派生类的成员,更好地分离关注点,并添加一些验证。为了把一个简明的例

c++ - 使用 cmake 添加 _CRT_SECURE_NO_WARNINGS 定义

是否可以使用cmake添加_CRT_SECURE_NO_WARNINGS预处理器定义?add_definitions(-CRT_SECURE_NO_WARNINGS)add_definitions(-_CRT_SECURE_NO_WARNINGS)add_definitions(_CRT_SECURE_NO_WARNINGS)这些是我到目前为止尝试过的。这些尝试都没有成功。 最佳答案 使用这个:if(MSVC)add_definitions(-D_CRT_SECURE_NO_WARNINGS)endif()参见here获取官方文档。

c++ - 制作 : pattern rule matching multiple extensions

我有几个扩展的重复模式规则(例如:cpp和cc):$(OBJ_DIR)/%.o:$(SRC_DIR)/%.cpp@$(CXX)$(CPPFLAGS)-I.-o$@-c$?$(OBJ_DIR)/%.o:$(SRC_DIR)/%.cc@$(CXX)$(CPPFLAGS)-I.-o$@-c$?有没有办法让一个模式规则在两个扩展上都匹配,而不是必须有两个规则? 最佳答案 不,您不能将这两个规则结合起来。所有先决条件都必须匹配。但是您可以避免需要两次指定配方。通过使用配方定义:defineCOMPILE@$(CXX)$(CPPFLAGS)-I

C++/线程 : No instance of constructor "std::thread::thread" > matches the argument list

我在线程方面遇到了一些问题,因为我对它很陌生。我得到一个:noinstanceofconstructor"std::thread::thread"matchestheargumentlistargumenttypesare(void())恰好在std::threadt1(TestPlay);voidCMusicTCPDlg::OnBnClickedBtplaymusic(){std::threadt1(TestPlay);t1.join();}voidCMusicTCPDlg::TestPlay(){if(CFugue::GetMidiOutPortCount()我引用了一些线程页面,

brew install报错Error: No developer tools installed. Error: Command failed with exit 128: git

先来解决第一个问题Error:Nodevelopertoolsinstalled.InstalltheCommandLineTools:xcode-select--installxcode-select--install然后升级一下brew,出现警告。然后再次尝试安装treebrewupdatebrew install tree出现如下错误:fatal:notinagitdirectoryError:Commandfailedwithexit128:git在终端输入brew-vHomebrew3.6.20fatal:detecteddubiousownershipinrepositoryat'

c++ - 反向迭代器错误 : no match for 'operator!=' in 'rcit != std::vector<_Tp, _Alloc>::rend() with _Tp = int, _Alloc = std::allocator'

代码A:vector::const_reverse_iteratorrcit;vector::const_reverse_iteratortit=v.rend();for(rcit=v.rbegin();rcit!=tit;++rcit)cout代码B:vector::const_reverse_iteratorrcit;for(rcit=v.rbegin();rcit!=v.rend();++rcit)coutCODEA工作正常但是为什么代码B通过错误:DEVC++\vector_test.cpp在'rcit!=std::vector::rend()与_Tp=int,_Alloc=s