草庐IT

bbva_deductions

全部标签

c++ - C++ "type deduction"和 Haskell "type inference"有什么区别?

在英语语义中,“typededuction”等于“typeinferring”吗?我不确定这只是不同语言设计者选择的成语偏好,或者计算机科学给出了严格的“类型推导”定义,哪个不是“类型推断”?谢谢。 最佳答案 C++规范和工作草案广泛使用“类型推导”来指代没有类型声明作为引用的表达式类型;例如thisworkingdraftonconcepts在谈论auto声明的变量时使用它,我记得很多书在谈论模板时都使用它,那时候我不得不学习——然后忘记了大部分——C++。Typeinference但是,它有自己的维基百科页面,也是编程语言理论中

C++ : Different deduction of type auto between const int * and cont int &

这里是代码示例。a.intii=0;b.constintci=ii;c.autoe=&ci;-->eisconstint*d.auto&f=42;-->invalidinitializationofnon-constreferenceoftype‘int&’fromanrvalueoftype‘int’e.constauto&g=42-->ok观察:1.对于c)子句,自动推导类型const2.对于子句d),不会自动推导出类型const3.对于条款e),必须手动添加类型const才能使其工作。为什么子句c而不是d会自动推导类型const? 最佳答案

c++ - reference_wrapper : make_pair VS Class Template Argument Deduction (CTAD)

为什么make_pair和类模板参数推导(CTAD)不同意生成哪种类型?#include#include#include#includeintmain(){intmyInt=5;std::reference_wrappermyIntRef=myInt;automyPair=std::make_pair(myInt,myIntRef);std::pairMy2ndPair(myInt,myIntRef);std::cout输出:St4pairIiRiE//std::pairSt4pairIiSt17reference_wrapperIiEE//std::pair>更新:为什么std::p

c++ - 依赖类型 : Template argument deduction failed

在我的代码中,我使用了模板化图像类Image结合std::shared_ptr.这些图像指针应该传递给各种图像处理函数,其中一些函数与图像类型无关。考虑以下Image的定义和两个处理函数function1()和function2().#includetemplatestructImage{typedefstd::shared_ptr>Ptr;};templatevoidfunction1(typenameImage::Ptrimage){}templatevoidfunction2(std::shared_ptr>image){}同时function1()和function2()实际上

c++ - "template argument deduction for class templates"是否应该为可变类模板推导出空参数包?

“类模板的模板参数推导”提案(P0091R2)包含以下示例:templatestructX{X(Ts...)};Xx1{1};//OKXXx11;//OKX(除了构造函数定义缺少主体这一事实之外),该示例似乎表明用零参数构造的可变参数类模板将被推导为一个空的参数包。很遗憾,最新版本的g++不同意:intmain(){Xx1{1};Xx11;}Infunction'intmain()':error:invaliduseoftemplate-name'X'withoutanargumentlistXx11;^note:classtemplateargumentdeductionrequir

MySQL CAST 确实需要它的甜蜜时光

因此,我在MySQL控制台中运行了以下命令作为控制测试,以了解是什么阻碍了我的查询速度。SELECTbbva_deductions.ded_code,SUBSTRING_INDEX(bbva_deductions.employee_id,'-',-1)AStt_emplid,bbva_job.paygroup,bbva_job.file_nbr,bbva_deductions.ded_amountFROMbbva_deductionsLEFTJOINbbva_jobONCAST(SUBSTRING_INDEX(bbva_deductions.employee_id,'-',-1)ASU

c++ - 可变参数模板作为模板参数 : deduction works with GCC but not with Clang

在使用GCC4.7.2和Clang3.1编译一些C++11代码时,我遇到了一个问题,即Clang无法推断出GCC成功的模板参数。在更抽象的形式中,代码如下所示:src/test.cc:structElement{};templatestructFirstContainer{};templatestructSecondContainer{};templateclassContainer>voidprocessOrdinary(Container/*elements*/){}templateclassContainer>voidprocessOrdinary(Container/*elem

c++ - 可变参数模板作为模板参数 : deduction works with GCC but not with Clang

在使用GCC4.7.2和Clang3.1编译一些C++11代码时,我遇到了一个问题,即Clang无法推断出GCC成功的模板参数。在更抽象的形式中,代码如下所示:src/test.cc:structElement{};templatestructFirstContainer{};templatestructSecondContainer{};templateclassContainer>voidprocessOrdinary(Container/*elements*/){}templateclassContainer>voidprocessOrdinary(Container/*elem

c++ - 返回 C++17 可变参数模板的可变参数聚合(结构)和语法 'construction deduction guide'

使用模板结构,例如下面的many,可以返回一组固定的可能不可移动的对象,并使用c++17结构化绑定(bind)(auto[a,b,c]=f();声明变量a、b和c并从分配它们的值f返回例如结构或元组)。templatestructmany{T1a;T2b;T3c;};//guide:templatemany(T1,T2,T3)->many;autof(){returnmany{string(),5.7,unmovable()};};intmain(){auto[x,y,z]=f();}如这两个问题和答案中所述(Dostd::tupleandstd::pairsupportaggrega