草庐IT

accept-parameters

全部标签

c++ - 使用 UNREFERENCED_PARAMETER 宏

我在VisualStudio上使用\W4警告级别并且我正在编写一个Windows程序。intWINAPIWinMain(HINSTANCEhInstance,HINSTANCEhPrevInstance,LPSTRlpCmdLine,intnCmdShow)所有这些参数都没有在我的应用程序中使用,所以我在编译时收到警告。我知道有两种处理方法:注释参数HINSTANCE/*hInstance*/...使用UNREFERENCED_PARAMETER宏intWINAPIWinMain(HINSTANCEhInstance,HINSTANCEhPrevInstance,LPSTRlpCmdL

c++ - std::error_code,my_error::check_block == my_error::validate && my_error::accept_block == my_error::validate

我正在使用std::error_code并定义和注册了一堆错误(使用枚举类)。我有一个非常通用的错误,现在称为my_error::validate,但我想在我的库中提供更具体的版本。通常人们会想要使用:if(ec==bc::error::validate)//...但是有时他们可能希望看到与该std::error_code关联的特定错误或打印错误消息。//ec.message()says"check_block()failedtodoXYZ"assert(ec==bc::error::check_block);我希望能够启用如下功能:if(ec==bc::error::validate

c++ - 如何允许 std :string parameter to be NULL?

我有一个函数foo(conststd::string&str);如果您使用foo(NULL)调用它,它确实会崩溃。我该怎么做才能防止它崩溃? 最佳答案 std::string有一个带有constchar*参数的构造函数。当您将NULL传递给它时,构造函数将崩溃,并且当您编写foo(NULL)时会隐式调用该构造函数。我能想到的唯一解决办法就是重载foovoidfoo(conststd::string&str){//yourfunction}voidfoo(constchar*cstr){if(cstr==NULL)//dosometh

c++ - "a declaration shadows a parameter"是什么意思?

我正在尝试创建一个函数,该函数返回我将传递给它的整数的两倍。我的代码收到以下错误消息:declarationof'intx'shadowsaparameterintx;"这是我的代码:#includeintdoublenumber();usingnamespacestd;intdoublenumber(intx)//>a;doublenumber(a);return0;} 最佳答案 您将x作为参数,然后尝试将其也声明为局部变量,这就是对“阴影”的提示。 关于c++-"adeclarati

c++ - std::apply forward parameters 如何在没有显式 std::forward 的情况下应用?

考虑std::apply的可能实现:namespacedetail{templateconstexprdecltype(auto)apply_impl(F&&f,Tuple&&t,std::index_sequence){returnstd::invoke(std::forward(f),std::get(std::forward(t))...);}}//namespacedetailtemplateconstexprdecltype(auto)apply(F&&f,Tuple&&t){returndetail::apply_impl(std::forward(f),std::forw

c++ - g++ 编译器错误 : couldn't deduce template parameter ‘_Funct’

我正在尝试使用ANSIC++for_each语句迭代并打印标准vector的元素。如果我让for_each调用一个非重载函数,它会工作,但如果我让它调用一个重载函数,则会产生编译器错误。这是一个最小的测试程序,用于显示编译器错误发生的位置:#include#include#includestructS{charc;inti;};std::vectorv;voidprint_struct(intidx);voidprint_struct(conststructS&s);//f:anon-overloadedversionoftheprecedingfunction.voidf(const

c++ - 错误 C2678 : binary '==' : no operator found which takes a left-hand operand of type (or there is no acceptable conversion)

我正在尝试编译以下代码:#include#include#includetypedefboost::geometry::model::d2::point_xyPoint;typedefstd::pairVector;booloperator==(constPoint&p1,constPoint&p2){returnp1.x()==p2.x()&&p1.y()==p2.y();}intmain(){Vectorvec1(Point(0,0),Point(1,1));Vectorvec2(Point(0,0),Point(1,2));std::coutVS2012C++编译器返回以下编译错

c++ - 模板编译失败 : 'double' is not a valid type for a template constant parameter

templateclassLowerBoundedType{};templateclassvectorelement{};templateclassvectorelement{typedefLowerBoundedTypetype;};有错误:error:'double'isnotavalidtypeforatemplateconstantparameter 最佳答案 唯一对非类型模板参数有效的数字类型是整数和枚举。因此,您不能拥有double类型的非类型模板参数。 关于c++-模板编译

windows - Build.xml 给出问题。 ."CreateProcess error=87, The parameter is incorrect"

我试图在Windows环境中使用ant构建脚本来执行我的java程序。但是我遇到了以下问题。这是在linux环境中工作的。[1]init:compile:stockquote:[java]C:\wso2esb-4.0.0-SNAPSHOT\samples\axis2Client\build.xml:128:java.io.IOException:Cannotrunprogram"C:\ProgramFiles\Java\jdk1.6.0_20\jre\bin\java.exe":CreateProcesserror=87,Theparameterisincorrect[java]ato

java - Tomcat : Doesn't accept the username and password, 无法查看Server Status,Manager App页面,为什么会这样?

我无法在Tomcat中查看服务器状态和管理器应用程序页面。虽然我在tomcat-users.xml中配置了用户名和密码,但它不接受组合并显示此消息:401UnauthorizedYouarenotauthorizedtoviewthispage.Ifyouhavenotchangedanyconfigurationfiles,pleaseexaminethefileconf/tomcat-users.xmlinyourinstallation.Thatfilemustcontainthecredentialstoletyouusethiswebapp.Forexample,toaddt