草庐IT

UMBA_STATIC_ASSERT

全部标签

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++ - 如何在 Visual Studio 2013 的 Debug模式下关闭 ASSERT

有什么方法可以关闭断言而不是切换到Release模式。我需要调试经常进行断言的代码,这会减慢我的工作速度。这些断言与我要解决的问题无关,所以现在它们只会减慢我的进度,因为它们在我的一个基类中经常被调用。现在我没有时间改进他们的设计,所以有人可以告诉我是否有办法在Debug模式下关闭断言并使用它的功能。 最佳答案 用户_CrtSetReportModeintiPrev=_CrtSetReportMode(_CRT_ASSERT,0);//StartOperationwithnoASSERTs...//Restorepreviousmo

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++ - 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-所有三个主要编译器似乎都按预期工作。我知道