草庐IT

is_constexpr_copiable

全部标签

c++ - constexpr - 函数不能用在常量表达式中

我想在编译时为给定范围内的数学函数计算一个查找表,然后在运行时从该表中检索值。我的代码如下:#include#includetemplateclassLookupTable{public:constexprLookupTable(doublexMin,doublexMax):array(),xMin(xMin),xMax(xMax),dx((xMax-xMin)/(size-1)){for(autoi=0;i((x-xMin)/dx),0),size-1)];}private:doublearray[size];doublexMin;doublexMax;doubledx;};intm

c++ - 带有 std::enable_if 和 std::is_default_constructible 的 SFINAE 用于 libc++ 中的不完整类型

我刚刚在使用SFINAE检测模板类型是否默认可构造时观察到libc++的一个奇怪问题。以下是我能够想出的一个最小示例:#include#includetemplatestructDummy;templatestructDummy{};templatestructhas_dummy:std::false_type{};templatestructhas_dummy>::value>>:std::true_type{};intmain(){std::cout{}(){}()它编译并输出预期的行true和false使用libstdc++使用g++或clang++编译时.但是,当我尝试使用li

c++ - 迭代器的后继不一定是正则函数 : how is it possible?

在ElementsofProgramming一书的第91页中,Stepanov和McJones说Iterator的概念需要一个successor函数,但这不一定正常因为...i=jdoesnotimplythatsuccessor(i)=successor(j)...(参见pageonline)我理解相反的successor(i)=successor(j)并不意味着i=j(例如在两个空终止列表中)并且某些输入可能未定义后继函数。但是我不明白i=j怎么可能导致successor(i)!=successor(j)。他们指的是什么情况?也许是一些随机(如随机)跳跃的迭代器?或某些具有隐藏状态

c++ - 对于具有抛出复制构造函数和 noexcept 按值复制赋值的类,is_nothrow_copy_assignable 的值是多少?

根据C++标准,以下程序的预期(如果有)输出是什么:#include#include#includeclassA{public:A()=default;~A()=default;A(Aconst&other){}A(A&&other)noexcept{}A&operator=(Aother)noexcept{return*this;}};intmain(){std::cout::value::value换句话说,类型特征值的评估是否只看赋值运算符的声明,即noexcept,并因此产生truetrue或者它是否考虑调用上下文(a、b是A的实例)a=b;//maythrow,implici

c++ - gcc 警告未使用的静态函数,但不是静态内联 : is there a practical distinction?

我的gcc版本(5.4)会警告未使用的static函数,即使在使用-Wall的头文件中也是如此。如果相同的函数定义为staticinline或只是inline,它不会提示。例如,文件unused.h中的以下函数:staticvoidfoo(){}...当包含在test.cpp文件中时,如下所示:#include"unused.h"当使用-Wall编译器时生成以下编译器诊断:Infileincludedfromtest.cpp:11:0:unused.h:Atglobalscope:unused.h:9:13:warning:‘voidfoo()’definedbutnotused[-W

c++ - constexpr 可变参数模板和解包 std::array

我想编写一个constexpr模板函数来置换作为参数传入的数组元素。所以我想出了这样的事情:templateconstexprstd::arraypermute(conststd::array&arr,conststd::array&permutation,Ts&&...processed){return(sizeof...(Ts)==N)?std::array{std::forward(processed)...}:permute(arr,permutation,std::forward(processed)...,arr[permutation[sizeof...(Ts)]]);}

c++ - Link Error : xxx is already defined in *****.LIB::究竟是什么错误?

问题:我正在尝试使用名为DCMTK的库它使用了一些其他外部库(zlib、libtiff、libpng、libxml2、libiconv)。我从同一网站下载了这些外部库(*.LIB和*.h文件)。现在,当我编译DCMTK库时,出现如下链接错误(793错误):Error2errorLNK2005:__encode_pointeralreadydefinedinMSVCRTD.lib(MSVCR90D.dll)LIBCMTD.libdcmmkdirError3errorLNK2005:__decode_pointeralreadydefinedinMSVCRTD.lib(MSVCR90D.d

2023版idea ssh 远程linux docker 报错: Only key-pair ssh auth type is supported for docker connections.

2023版ideassh远程linuxdocker报错:Cannotconnect:java.lang.llegalArgumentException:Onlykey-pairsshauthtypeissupportedfordockerconnections.环境:idea2023.3.2centos7安装docker报错截图:正确操作步骤:idea选择连接方式ssh点“+”号依次填入信息,点击“testConnection”,初次会报错,参考第4步报错,可以忽略,点击“OK”依次点击“Apply”,点击“OK”,关闭此界面下面的弹窗也“OK”关闭双击此处“Docker”,即可连接成功,再次

C++1y/C++14 : Converting static constexpr array to non-type template parameter pack?

假设我有一个静态存储持续时间的constexpr数组(已知范围):constexprTinput[]=/*...*/;我有一个需要打包的输出类模板:templatestructoutput_template;我想像这样实例化output_template:usingoutput=output_template;一种方法是:templatestructmake_output_template{templatestaticconstexproutput_templatef(std::index_sequence){return{};};usingtype=decltype(f(std::m

网格到网格相交的 C++ 库 : what is available?

我需要计算3D三角形网格(例如.obj格式)之间的体积相交和穿透深度,但我对计算几何还很陌生。在之前的帖子(Meshtomeshintersections)和我的谷歌搜索中,我发现了一些可能适合完成这项工作的C++库:CGALPQP自由迅捷不过,我不确定哪一个最适合初学者。有什么建议吗? 最佳答案 libigl从1.1版开始,igl/boolean/mesh_boolean.h中具有强大的网格bool运算。这使用使用CGAL的精确算术内核的实现或cork的包装器(您的另一种选择)。目前,libigl还在libigl/external