草庐IT

SOME_CONSTANT

全部标签

C++1y/C++14 : Assignment to object outside its lifetime is not allowed in a constant expression?

根据当前草案,以下C++14/C++1y程序是否格式错误?#includetemplatestructliteral_array{Tdata[n];};templateconstexprliteral_arrayoperator+(literal_arraya,literal_arrayb){literal_arrayx;for(size_ti=0;ia={1,2,3};constexprliteral_arrayb={4,5};constexprautoc=a+b;}Clangtrunk(在撰写本文时)给出:error:constexprvariable'c'mustbeinitia

C++1y/C++14 : Assignment to object outside its lifetime is not allowed in a constant expression?

根据当前草案,以下C++14/C++1y程序是否格式错误?#includetemplatestructliteral_array{Tdata[n];};templateconstexprliteral_arrayoperator+(literal_arraya,literal_arrayb){literal_arrayx;for(size_ti=0;ia={1,2,3};constexprliteral_arrayb={4,5};constexprautoc=a+b;}Clangtrunk(在撰写本文时)给出:error:constexprvariable'c'mustbeinitia

c++ - 有没有一种正统的方法来避免编译器警告 C4309 - "truncation of constant value"与二进制文件输出?

我的程序执行将二进制数据写入文件的常见任务,符合某种非文本文件格式。由于我正在写入的数据尚未存在于现有block中,而是在运行时逐字节放在一起,因此我使用std::ostream::put()而不是write().我认为这是正常程序。该程序运行良好。它同时使用std::stringstream::put()和std::ofstream::put()以两位十六进制整数作为参数。但是我得到编译器警告C4309:"truncationofconstantvalue"(inVC++2010)每当参数到put()大于0x7f。显然编译器期待signedchar,常数超出范围。但我认为实际上并没有

c++ - 有没有一种正统的方法来避免编译器警告 C4309 - "truncation of constant value"与二进制文件输出?

我的程序执行将二进制数据写入文件的常见任务,符合某种非文本文件格式。由于我正在写入的数据尚未存在于现有block中,而是在运行时逐字节放在一起,因此我使用std::ostream::put()而不是write().我认为这是正常程序。该程序运行良好。它同时使用std::stringstream::put()和std::ofstream::put()以两位十六进制整数作为参数。但是我得到编译器警告C4309:"truncationofconstantvalue"(inVC++2010)每当参数到put()大于0x7f。显然编译器期待signedchar,常数超出范围。但我认为实际上并没有

c++ - 为什么我们需要两个定义: integral constant expression and converted constant expression?

C++14中的§5.19/3定义了一个整型常量表达式和一个转换后的常量表达式:Anintegralconstantexpressionisanexpressionofintegralorunscopedenumerationtype,implicitlyconvertedtoaprvalue,wheretheconvertedexpressionisacoreconstantexpression.[Note:Suchexpressionsmaybeusedasarraybounds(8.3.4,5.3.4),asbit-fieldlengths(9.6),asenumeratorini

c++ - 为什么我们需要两个定义: integral constant expression and converted constant expression?

C++14中的§5.19/3定义了一个整型常量表达式和一个转换后的常量表达式:Anintegralconstantexpressionisanexpressionofintegralorunscopedenumerationtype,implicitlyconvertedtoaprvalue,wheretheconvertedexpressionisacoreconstantexpression.[Note:Suchexpressionsmaybeusedasarraybounds(8.3.4,5.3.4),asbit-fieldlengths(9.6),asenumeratorini

C++ 警告 : deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]

我正在使用gnuplot在C++中绘制图形。该图正在按预期绘制,但在编译期间出现警告。警告是什么意思?warning:deprecatedconversionfromstringconstantto‘char*’[-Wwrite-strings]这是我正在使用的功能:voidplotgraph(doublexvals[],doubleyvals[],intNUM_POINTS){char*commandsForGnuplot[]={"settitle\"ProbabilityGraph\"","plot'data.temp'withlines"};FILE*temp=fopen("da

C++ 警告 : deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]

我正在使用gnuplot在C++中绘制图形。该图正在按预期绘制,但在编译期间出现警告。警告是什么意思?warning:deprecatedconversionfromstringconstantto‘char*’[-Wwrite-strings]这是我正在使用的功能:voidplotgraph(doublexvals[],doubleyvals[],intNUM_POINTS){char*commandsForGnuplot[]={"settitle\"ProbabilityGraph\"","plot'data.temp'withlines"};FILE*temp=fopen("da

python多处理: some functions do not return when they are complete (queue material too big)

我正在使用多处理的进程和队列。我并行启动了几个函数,并且大多数函数都表现良好:它们完成,它们的输出进入它们的队列,它们显示为.is_alive()==False。但是由于某种原因,一些函数没有运行。它们总是显示.is_alive()==True,即使在函数的最后一行(打印语句说“完成”)完成之后也是如此。无论我启动了哪些功能,都会发生这种情况,即使它只有一个。如果不并行运行,则函数运行良好并正常返回。什么种类可能是问题?这是我用来管理作业的通用函数。我没有展示的只是我传递给它的函数。它们很长,经常使用matplotlib,有时会启动一些shell命令,但我不知道失败的命令有什么共同点。

python多处理: some functions do not return when they are complete (queue material too big)

我正在使用多处理的进程和队列。我并行启动了几个函数,并且大多数函数都表现良好:它们完成,它们的输出进入它们的队列,它们显示为.is_alive()==False。但是由于某种原因,一些函数没有运行。它们总是显示.is_alive()==True,即使在函数的最后一行(打印语句说“完成”)完成之后也是如此。无论我启动了哪些功能,都会发生这种情况,即使它只有一个。如果不并行运行,则函数运行良好并正常返回。什么种类可能是问题?这是我用来管理作业的通用函数。我没有展示的只是我传递给它的函数。它们很长,经常使用matplotlib,有时会启动一些shell命令,但我不知道失败的命令有什么共同点。