草庐IT

is_constexpr_copiable

全部标签

c++ - constexpr if with initializer 由标准保证吗? 'constexpr(constexpr auto x = f(); x) { }'

我找不到任何关于新C++17if初始化语法的信息和“constexprif”在:http://open-std.org/JTC1/SC22/WG21/docs/papers/2016/p0128r1.html不过,Clang-HEAD支持该语法...constexprautof(){returntrue;}intmain(){ifconstexpr(constexprautox=f();x){}}在线代码在这里->http://melpon.org/wandbox/permlink/dj3a9ChvjhlNc8nr是constexprif带有标准保证的初始值设定项,如constexpr

c++ - 具有可变成员的 constexpr 对象

我想到了这个类:classPoint{public:intX,Y;mutableintZ;constexprPoint(intx,inty):X(x),Y(y),Z(0){}constexprintGetX()const{//Z++;//Wontcompile,butfollowingexpressionisvalid!returnX+Z;}intGetY()const{Z++;returnY;}voidFoolConst()const{Z++;}};这里是用法:templatevoidfoo(){std::cout();//GCCfails,VCcompilesstd::cout问题

c++ - 构造函数被继承时的 std::is_nothrow_constructible

考虑以下两个示例:structA{A()noexcept=default;};structB:A{B()noexcept=default;templateB(T)noexcept{}};structC:A{usingA::A;templateC(T)noexcept{}};和用法:std::cout::value::value::value::value输出是:1101使用的编译器:GCC4.8.1。因此,如果我显式编写默认的B构造函数,(X)会生成1,另一方面,如果默认的C构造函数可用由于继承,(Y)产生0。这是为什么?这是否意味着在使用is_nothrow_constructibl

c++ - 继承和 is_detected_v 提供了一个奇怪的结果 (C++17)

我有简化版的代码:#includetemplateusinghas_data_t=decltype(T::data());templateconstexprautoget_data(){returnstd::experimental::is_detected_v;}templatestructopt_base{staticconstexprbooli=get_data();//staticconstexprautoj=get_data();//failtocompile};structopt:publicopt_base{staticintdata(){return7;}};intma

c++ - 错误 : ‘template<class> class std::auto_ptr’ is deprecated

我正在使用scons和ubuntu。当我使用'scons'制作一些程序时,会发生错误,例如,src/db/DBTextLoader.cc:296:3:error:‘templateclassstd::auto_ptr’isdeprecated[-Werror=deprecated-declarations]/usr/include/c++/5/bits/unique_ptr.h:49:28:note:declaredheretemplateclassauto_ptr;这是我的命令;$./configuer$sourcesomething.sh$scons其实我也不知道。我已经在搜索这个

c++ - Clang 声称通用 lambda 参数的 constexpr 成员不是 constexpr

我想编写一个通用的lambda作为变体的访问者。这个变体的成员包含一个constexpr成员值,我想在访问者中使用它。例如:#includetemplatestructS{constexprstaticintthis_r=r;};intf(std::variant,S,S>v){returnstd::visit([](autoconst&arg){ifconstexpr(arg.this_r==0){return42;}else{returnarg.this_r;}},v);}intg(){std::variant,S,S>x=S();returnf(x);}GCC乐于从大约versi

Error: Microsoft Visual C++ 14.0 or greater is required 我的解决办法

今天想进行特征提取,利用的是mRMR方法,想安装一个pymrmr的库,但是给出了缺少MicrosoftC++BuildTools报错,我来记录一下我的解决过程。这里写目录标题一、报错,缺少MicrosoftC++BuildTools二、安装步骤1.打开链接2.点击下载生成工具3.只需要安装“使用C++的桌面开发”4.因为实在太大了,更改安装路径(要是你们C盘内存够用的话,这一项不用操作)5.只更改第一项路径,其余路径不用动,否则会报错。(要是你们C盘内存够用的话,这一项不用操作)6.安装还是很快的,取决于你的网速。7.重启电脑,一定要重启。8.进行pip安装库一、报错,缺少MicrosoftC

K8S异常之Unable to connect to the server: x509: certificate has expired or is not yet valid

一、问题:k8s证书过期[root@nb001~]#kubectlgetnodeUnabletoconnecttotheserver:x509:certificatehasexpiredorisnotyetvalid:currenttime2022-12-10T10:26:21+08:00isafter2022-12-10T01:55:52Z二、解决方案:2.1处理步骤#备份kubernetes配置cp-r/etc/kubernetes/etc/kubernetes_bak#检测证书过期kubeadmcertscheck-expiration#更新证书kubeadmcertsrenewall2

c++ - Soft (not : weak) references in C++ - Is it possible? 有实现吗?

在C++中,我使用boost::shared_ptr和boost::weak_ptr自动删除不再需要的对象。我知道这些与引用计数一起工作。在Java中,内存由垃圾收集器管理,垃圾收集器将内置对象引用视为strong,将WeakReference视为weak并且SoftReference作为介于两者之间的东西(可能被GC收集,但也可能在GC中幸存下来),这对于缓存对象一段时间非常方便,但一旦可用内存变低就将它们丢弃。所以现在我又回到了C++中,我想念软引用带来的舒适感。我想知道软引用是否完全适用于引用计数。当对象的最后一个strong引用被清除,并且还剩下一个soft引用时,到底什么时候

c++ - 错误消息 : 'value_type' : is not a member of

我不明白这个神秘的错误消息,但我得到了30个`'value_type':isnotamemberof'TextFileLineBuffer'`当我在VC++6中编译以下代码时,//***行未注释。当然,如果我把它注释掉,它编译得很好。我想我在过去的两个小时里尝试了各种尝试,但都没有成功。任何提示将不胜感激。#include#include#include#include#include#include//wrapperforastringlinestructTextLine{std::stringm_sLineContent;operatorstd::stringconst&()con