草庐IT

static_warning

全部标签

c++ - boost 二进制 static_visitor 和 apply_visitor

我有以下代码:typedefboost::variantSearchParameter;enumVisibility{CLEAR,CLOUDY,FOG,SMOKE};classDetectionGenerator:publicboost::static_visitor{public:DetectionGenerator(constEnvironmentalFactors&factors);doubleoperator()(constLandSearchParameter&land,Visibilityvis)const;doubleoperator()(constWaterSearch

c++ - 这段代码是做什么的 : static union MSVC_EVIL_FLOAT_HACK INFINITY_HACK = {{0x00, 0x00, 0x80, 0x7F}};

#ifndefINFINITY#ifdef_MSC_VERunionMSVC_EVIL_FLOAT_HACK{unsigned__int8Bytes[4];floatValue;};staticunionMSVC_EVIL_FLOAT_HACKINFINITY_HACK={{0x00,0x00,0x80,0x7F}};#defineINFINITY(INFINITY_HACK.Value)#endif我目前正在开始使用Chipmunk物理引擎并在头文件中找到它INFINITY用于为物体设置无限动量,但是我不明白上面这段代码的作用! 最佳答案

c++ - "Warning: corrupt .drectve at end of def file"是什么意思?

这个问题在这里已经有了答案:Warning:corrupt.drectveatendofdeffile(3个答案)关闭去年。在这个环境下,我编译了一个c++/openGL的例子贴在网上:Windows7代码::Blocksv13.12MinGW构建于2013年10月(不确定版本)mingw32-g++v4.8.1来自codeincodeblock.com的代码:#defineGLEW_STATIC//third-partylibraries#include#include#include#include#include#include#includeGLuintgVAO=0;GLuin

c++ - static_assert 和英特尔 C++ 编译器

阅读cppreference.com:Astaticassertdeclarationmayappearatblockscope(asablockdeclaration)andinsideaclassbody(asamemberdeclaration)好的,现在我有以下代码:structfoo_t{staticconstexprstd::size_tmaxAlignment(){//Thisisjustasample;Iremovedrealcodefromthismethod.returnstd::max(alignof(__m128),__alignof(__m256));}sta

c++ - static_assert 无法将 const char* 模板参数识别为 constexpr : g++ bug?

考虑以下定义。charright_string[]="::right_one.";charwrong_string[]="::wrong_one.";templatevoidf(){static_assert(str==::right_string,"Passme::right_string!");}structTest{staticconstexprcharright_string[]="template_struct::right_one";staticconstexprcharwrong_string[]="template_struct::wrong_one";template

java - Kotlin for android 和 static final 内部类

我正在尝试在Kotlin上重写我的android应用程序,并且在转换ContentProvider契约(Contract)类时遇到了问题。所以我有简单的契约(Contract)类(内容类型和内容uris等默认内容被省略):publicfinalclassContract{publicstaticfinalclassContacts{publicstaticfinalStringNAME="Name"publicstaticfinalStringBIRTH="Birth"publicstaticfinalStringIMAGE="Image"}}如果我理解正确,在Kotlin中我们没有静

java - Kotlin for android 和 static final 内部类

我正在尝试在Kotlin上重写我的android应用程序,并且在转换ContentProvider契约(Contract)类时遇到了问题。所以我有简单的契约(Contract)类(内容类型和内容uris等默认内容被省略):publicfinalclassContract{publicstaticfinalclassContacts{publicstaticfinalStringNAME="Name"publicstaticfinalStringBIRTH="Birth"publicstaticfinalStringIMAGE="Image"}}如果我理解正确,在Kotlin中我们没有静

c++ - 类型特征 : Check if reference member variable is static or not

我想检查一个类的成员变量是否是静态的。使用std::is_member_pointer适用于除引用成员之外的所有类型。#includestructA{intfoo;};structB:A{};structC{staticintfoo;};structD:C{};structE{int&foo;};structF{staticint&foo;};static_assert(std::is_member_pointer::value,"No");static_assert(std::is_member_pointer::value,"No");static_assert(!std::is_

c++ - 工厂、unique_ptr 和 static_cast

考虑具有基对象、派生接口(interface)和最终对象的多态类://baseobjectstructobject{virtual~object()=default;};//interfacesderivedfrombaseobjectstructinterface1:object{virtualvoidprint_hello()const=0;templatestaticvoidon_destruction(object*/*ptr*/){std::cout在实际用例中,最终对象是通过插件系统定义的,但这不是重点。请注意,我希望能够在销毁对象时调用on_destruction(请参阅

c++ - 仅在实例化时使用 `static_assert` 使类模板特化无法编译的安全、符合标准的方法?

假设我们想要制作一个模板类,它只能用数字实例化,否则不能编译。我的尝试:#includetemplatestructOnlyNumbers{public:structC{};static_assert(std::is_same::value,"Tisnotarithmetictype.");//OnlyNumbers*ptr;};templatestructOnlyNumbers>>{};structFoo{};intmain(){OnlyNumbers{};//Compiles//OnlyNumbers{};//Error}Livedemo-所有三个主要编译器似乎都按预期工作。我知道