草庐IT

non-matching

全部标签

C++ : friend declaration ‘declares a non-template function

我在重载时遇到问题流运算符(operator),我找不到解决方案:templateclassNVector{inlinefriendstd::ostream&operator&rhs);};templateinlinestd::ostream&NVector::operator&rhs){/*SOMETHING*/returnlhs;};它产生以下错误信息:warning:frienddeclaration‘std::ostream&operatorerror:‘std::ostream&NVector::operator如何解决这个问题?非常感谢。 最佳答

c++ - "error: no matching function for call to"

我当时在键盘上,我正在尝试使用C++来提高我的技能。我以前从未使用过模板,所以我尝试研究如何使用它们。下面的代码是结果,不幸的是,它不起作用。我确实尝试寻找问题的解决方案,但由于我没有太多使用模板的经验,所以我无法在我的问题和其他问题之间建立任何联系。所以,我决定寻求帮助。templateclassVector2{public:Ax,y;Vector2(Axp,Ayp){this->x=xp;this->y=yp;}};templateclassrayToCast{public:rayToCast(Bangle,Vector2origin,Vector2point1,Vector2po

C++ 错误 : request for member '...' in 'grmanager' which is of non-class type 'GraphicsManager'

这个问题不太可能帮助任何future的访问者;它只与一个小的地理区域、一个特定的时间点或一个非常狭窄的情况有关,这些情况并不普遍适用于互联网的全局受众。为了帮助使这个问题更广泛地适用,visitthehelpcenter.关闭10年前。我的类GraphicsManager出现错误。图形管理器.cpp:#include"C:\Users\ChrisUzzolina\Desktop\obj\include\GraphicsManager.h"#include#includeGraphicsManager::GraphicsManager(intSCREEN_WIDTH,intSCREEN_

c++ - 为什么 regex_match 抛出 "complexity exception"?

我正在尝试测试(使用boost::regex)文件中的一行是否仅包含由空格分隔的数字条目。我遇到了一个我不明白的异常(见下文)。如果有人能解释为什么抛出它,那就太好了。也许我在这里以定义模式的方式做了一些愚蠢的事情?这是代码://regex_test.cpp#include#include#includeusingnamespacestd;usingnamespaceboost;intmain(){//Mybasicpatterntotestforasinglenumericexpressionconststringnumeric_value_pattern="(?:-|\\+)?[[

c++ - const ref lvalue to non-const func return value 是否专门减少拷贝?

我遇到了一个C++习惯,我试图研究它以了解它的影响并验证它的用法。但我似乎找不到确切的答案。std::vectorgetThings();voiddo(){conststd::vector&things=getThings();}这里我们有一些返回非const&值的函数。我看到的习惯是在分配函数的返回值时使用const&左值。提出这个习惯的原因是它减少了拷贝。现在我一直在研究RVO(返回值优化)、复制省略和C++11移动语义。我意识到给定的编译器可以选择阻止通过RVO进行复制,不管这里是否使用了const&。但是,在防止复制方面,const&左值的使用对非const&返回值有任何影响吗

c++ - 编译cuda文件报错: "runtime library" mismatch value 'MDd_DynamicDebug' doesn't match value 'MTd_StaticDebug' in vectorAddition_cuda. o

我尝试在Qt5.2和MSVC2012环境下编译一个cuda文件。在开始我的项目之前,我仔细阅读了问题并回复:CompilingCudacodeinQtCreatoronWindows.但是即使我简单地复制代码并在qt中生成2个文件,仍然会弹出一些错误/main.cpp/vectorAddition.cu错误是:errorLNK2038:mismatchdetectedfor'RuntimeLibrary':value'MDd_DynamicDebug'doesn'tmatchvalue'MTd_StaticDebug'invectorAddition_cuda.o我完全不知道如何修复这

c++ - eclipse c++ 中的 "control reaches end of non-void function"警告但没有编译或运行时错误

这是我的代码:Composer&Database::GetComposer(stringin_last_name){for(inti=0;i想法是遍历Composer对象数组并返回对其last_name字段与“in_last_name”匹配的对象的引用。我明白警告在告诉我什么,即函数可能不会返回任何内容(如果用户提供了无效的姓氏)。我的问题是,我怎样才能避免这种情况?我尝试在for循环之后添加“return0”和“returnNULL”,但它无法编译。如果此方法什么也没找到,是否应该抛出异常? 最佳答案 您的函数被声明为返回一个Co

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++ - 铿锵错误 : non-const lvalue reference cannot bind to incompatible temporary

我有一段代码可以在MSVC上正常工作,但无法用clang++编译voidMyCass::someMethod(){std::wstringkey(...);auto&refInstance=m_map.find(key);//errorhere}其中m_map定义为std::map>m_map;和clang提示non-constlvaluereferencecannotbindtoincompatibletemporary我有点了解正在创建一个临时文件,但不确定如何解决这个问题。有什么想法吗? 最佳答案 右值不能绑定(bind)到非

C++1y/C++14 : Converting static constexpr array to non-type template parameter pack?

假设我有一个静态存储持续时间的constexpr数组(已知范围):constexprTinput[]=/*...*/;我有一个需要打包的输出类模板:templatestructoutput_template;我想像这样实例化output_template:usingoutput=output_template;一种方法是:templatestructmake_output_template{templatestaticconstexproutput_templatef(std::index_sequence){return{};};usingtype=decltype(f(std::m