草庐IT

implicit-conversion

全部标签

c++ - 了解复制初始化和隐式转换

我无法理解为什么以下复制初始化无法编译:#includestructbase{};structderived:base{};structtest{test(std::unique_ptr){}};intmain(){autopd=std::make_unique();//testt(std::move(pd));//thisworks;testt=std::move(pd);//thisdoesn't}一个unique_ptr可以移动到unique_ptr,那么为什么第二个语句有效,而最后一个语句无效?执行复制初始化时是否不考虑非显式构造函数?来自gcc-8.2.0的错误是:conve

Python 3.5+ : How to dynamically import a module given the full file path (in the presence of implicit sibling imports)?

问题标准库明确记录howtoimportsourcefilesdirectly(给定源文件的绝对文件路径),但如果源文件使用下面示例中描述的隐式同级导入,则此方法不起作用。如果存在隐式同级导入,该示例如何适应工作?我已经checkoutthis和thisotherStackoverflow有关该主题的问题,但它们没有解决手动导入的文件内的隐式同级导入。设置/示例这是一个说明性示例目录结构:root/-directory/-app.py-folder/-implicit_sibling_import.py-lib.pyapp.py:importosimportimportlib.util

Python 3.5+ : How to dynamically import a module given the full file path (in the presence of implicit sibling imports)?

问题标准库明确记录howtoimportsourcefilesdirectly(给定源文件的绝对文件路径),但如果源文件使用下面示例中描述的隐式同级导入,则此方法不起作用。如果存在隐式同级导入,该示例如何适应工作?我已经checkoutthis和thisotherStackoverflow有关该主题的问题,但它们没有解决手动导入的文件内的隐式同级导入。设置/示例这是一个说明性示例目录结构:root/-directory/-app.py-folder/-implicit_sibling_import.py-lib.pyapp.py:importosimportimportlib.util

python - future 警告 : Conversion of the second argument of issubdtype from `float` to `np.floating` is deprecated

更新我的Numpy和Tensorflow后,我收到了这些警告。我已经尝试过these,但没有任何效果,每一个建议都将不胜感激。FutureWarning:Conversionofthesecondargumentofissubdtypefrom`float`to`np.floating`isdeprecated.Infuture,itwillbetreatedas`np.float64==np.dtype(float).type`.from._convimportregister_convertersas_register_converters2018-01-1917:11:38.69

python - future 警告 : Conversion of the second argument of issubdtype from `float` to `np.floating` is deprecated

更新我的Numpy和Tensorflow后,我收到了这些警告。我已经尝试过these,但没有任何效果,每一个建议都将不胜感激。FutureWarning:Conversionofthesecondargumentofissubdtypefrom`float`to`np.floating`isdeprecated.Infuture,itwillbetreatedas`np.float64==np.dtype(float).type`.from._convimportregister_convertersas_register_converters2018-01-1917:11:38.69

warning: #68-D: integer conversion resulted in a change of sign

在学习STM32的时候遇到一个很奇怪的warning乍一看这就是一个很常见的定义变量且赋值的语句,感觉没有什么毛病。但是仔细看这是一个u8类型的变量,并且编译显示整数转换导致了符号的改变。所以问题应该就是变量的类型混淆所造成的。咱们深入keil内部去看看u8的本质是什么:这样就很明显了,u8-->uint8_t-->unsignedchar;所以编译出现整数转换导致了符号的改变的问题也就能理解了,因为这个变量类型按理来说是没有符号的,所以如果想要解决这个问题,只用把本例中result的初值改为正数就好。那为什么同样的东西,设计者要采用这么多名字呢?其实一方面就是为了程序员在编写代码的时候能最大

java - 改变行为可能导致精度损失

在Java中,当你这样做时intb=0;b=b+1.0;您可能会丢失精度错误。但是如果你这样做了,为什么会这样intb=0;b+=1.0;没有错误吗? 最佳答案 这是因为b+=1.0;等价于b=(int)((b)+(1.0));。narrowingprimitiveconversion(JLS5.1.3)隐藏在复合赋值操作中。JLS15.26.2CompoundAssignmentOperators(JLS第三版):AcompoundassignmentexpressionoftheformE1op=E2isequivalentto

java - 改变行为可能导致精度损失

在Java中,当你这样做时intb=0;b=b+1.0;您可能会丢失精度错误。但是如果你这样做了,为什么会这样intb=0;b+=1.0;没有错误吗? 最佳答案 这是因为b+=1.0;等价于b=(int)((b)+(1.0));。narrowingprimitiveconversion(JLS5.1.3)隐藏在复合赋值操作中。JLS15.26.2CompoundAssignmentOperators(JLS第三版):AcompoundassignmentexpressionoftheformE1op=E2isequivalentto

java - 不一致的 "possible lossy conversion from int to byte"编译时错误

检查以下代码片段:片段#1inta=20;intb=30;bytec=(a>b)?20:30;Error:incompatibletypes:possiblelossyconversionfrominttobytebytec=(a>b)?20:30;片段#2inta=20;intb=30;byteh1=70;bytec=(a>b)?20:h1;片段#3inta=20;intb=30;byteh1=70;byteh2=89;bytec=(a>b)?h1:h2;片段#4bytec=(true)?20:30;除了Snippet#1之外,所有这些都可以正常编译。这种行为如何合理?如果Snipp

java - 不一致的 "possible lossy conversion from int to byte"编译时错误

检查以下代码片段:片段#1inta=20;intb=30;bytec=(a>b)?20:30;Error:incompatibletypes:possiblelossyconversionfrominttobytebytec=(a>b)?20:30;片段#2inta=20;intb=30;byteh1=70;bytec=(a>b)?20:h1;片段#3inta=20;intb=30;byteh1=70;byteh2=89;bytec=(a>b)?h1:h2;片段#4bytec=(true)?20:30;除了Snippet#1之外,所有这些都可以正常编译。这种行为如何合理?如果Snipp