草庐IT

static-data

全部标签

c++ - "container"和 "data structure"有什么区别?

什么是容器?据我了解:抽象数据类型只是对数据存储方式和允许对该数据进行的操作的逻辑描述。例如,堆栈被定义为具有压入、弹出等操作和后进先出访问的数据类型。一个数据结构就是这个抽象定义的实际实现,在一些计算机编程语言中,例如C++中的栈,在标准库中的实现是std::stack。首先,请纠正/加强我目前对上述区别的理解。其次,容器到底是什么?我经常听到这个词。和我定义的数据结构一样吗?此外,维基百科为这些术语提供了三个单独的条目。 最佳答案 没什么,真的。正如我们人类喜欢做的那样,它们只是同一个词的两个词。然而,afaik,官方CS术语是

c++ - 通过 decltype 表达式调用时 static_assert 是否应该工作?

我预计以下代码会因最后一行的static_assert检查而失败。但是在MSVC2015和gcc6.2中,它编译成功。它确实无法按预期在clang3.9中进行编译。这是编译器错误还是static_assert在decltype()中不起作用?#include#includetemplatestructWrapper{};templateconstexprstd::tupleoperator|(Wrapper,Wrapper){static_assert(std::is_same::value==false,"can'tcombinetwoofthesametype");returnst

c++ - 轻松地将许多重要的 "static library projects"重构为 "dll projects"

我有6个静态库项目:--Math-ECS:dependsonMath-Utility:dependsonECS-Physics:dependsonUtility-Graphics:dependsonUtility-BaseGame:dependsonPhysicsandGraphics-Somegame(.exe):dependsonBaseGame(The"depends"hereistransitivee.g.BaseGamealsodependsonECS.)我通过“静态库”技术成功地使用了6个项目。今天听说动态库可以减少编译时间(暂且不讨论是否属实),所以我阅读了以下链接并成功

c++ - 为什么我不能使用 static_cast<int&> 将整数引用参数传递给 C++ 中的函数?

我在C++程序中有一个枚举参数,我需要使用一个通过参数返回值的函数来获取它。我首先将其声明为int,但在代码审查时被要求将其键入为枚举(ControlSource)。我这样做了,但它破坏了Get()函数——我注意到C风格的转换为int&解决了这个问题,但是当我第一次尝试用static_cast修复它时,它没有编译。为什么会这样,为什么当eTimeSource是一个int时根本不需要强制转换来通过引用传递整数?//GetCuePropertyValuesignatureis(intcueId,intpropertyId,int&value);ControlSourceeTimeSourc

c++ - 我可以在类定义中放置 "non-static blocks"代码吗?

C++中有非静态block吗?如果不是,如何优雅地模拟?我想替换像这样的东西:-classC{public:voidini(){/*somecode*/}};classD{std::vectorregis;//willini();laterpublic:Cfield1;public:Cfield2;public:Cfield3;//wheneverIaddanewfield,Ihaveto...#1public:D(){regis.push_back(&field1);regis.push_back(&field2);regis.push_back(&field3);//#1...al

c++ - 如何告诉 static_assert constexpr 函数参数是 const?

我有一个看起来像这样的constexpr函数:constexprintfoo(intbar){static_assert(bar>arbitrary_number,"Usealowernumberplease");returnsomething_const;}但是,用GCC4.6.3编译这个一直告诉我错误:'bar'不能出现在常量表达式中我试过类似的东西constexprintfoo(constexprconstintbar){static_assert(bar>arbitrary_number,"Usealowernumberplease");returnsomething_cons

c++ - 为什么在 C++ 中不允许初始化整数成员变量(不是 const static)?

当我尝试在类定义中初始化一个int成员变量时,我的C++编译器报错。它告诉“只能在类中初始化静态常量整数数据成员”。您能否解释此限制背后的基本原理(如果可能,举例说明)。 最佳答案 因为目前的标准是不允许的。AccordingtoBjarne,您将能够在C++0x中执行此操作。如果您确实需要它,请尝试将编译器设置为C++0x(GCC中的-std=c++0x)并查看您的编译器是否支持它。 关于c++-为什么在C++中不允许初始化整数成员变量(不是conststatic)?,我们在Stack

c++ - 为什么我们需要将 const 放在函数头的末尾,但首先是 static?

我有这样的代码...classTime{public:Time(int,int,int);voidset_hours(int);voidset_minutes(int);voidset_seconds(int);intget_hours()const;intget_minutes()const;intget_seconds()const;staticvoidfun();voidprintu()const;voidprints();private:intx;inthours;intminutes;intseconds;constinti;};为什么我需要在最后放置const来创建一个函数

c++ - 未定义的行为会影响 static_assert 吗?

考虑以下代码:SomeTypex=getX();for(automask=1u=sizeofx,"Typeofnumericparameteristoolong");/*...*/}此处,mask的类型为unsigned。假设SomeType是longlong。然后mask的初始化将由于移位太多而具有未定义的行为。但是OTOH,有一个static_assert,它检查未定义的行为不会在运行时发生(因为代码将无法编译)。但由于UB会导致时间悖论和其他意外情况,我不太确定static_assert能否保证在这种情况下实际工作。有什么理由可以确定这一点吗?或者是否应该重做此代码以使stati

r data.table和string_elt()错误:如何修复“字符矢量” vs'char'错误?

从r3.3更新到r3.4后,我在使用时有一个错误data.table包裹:STRING_ELT()canonlybeappliedtoa'charactervector',nota'char'有人经历过吗?我正在考虑降级以“修复”此操作。这是我的会话信息:>sessionInfo()Rversion3.4.0(2017-04-21)Platform:x86_64-pc-linux-gnu(64-bit)Runningunder:Ubuntu16.04.2LTSMatrixproducts:defaultBLAS:/usr/lib/libblas/libblas.so.3.6.0LAPACK:/