草庐IT

enable-flex

全部标签

c++ - 将 yyin 更改为 argv[1] Flex & Bison

我正在从事Flex&Bison项目。我的flex&bison运行良好,但我正在尝试将argv作为输入(yyin)。所以我改变了yyin以便它接受argv[1]但它实际上不起作用。似乎它采用了argv[1],但后来我得到了一个语法错误,即使我认为我的字符串可以完美地工作。这是我的弹性:%{#include"parser.hpp"externintyyparse();%}%optionnoyywraptexte[a-zA-z]+entier[0-9]+(\.[0-9])?%%{entier}{yylval.num=atoi(yytext);return(NUMBER);}"pi"retur

c++ - 为什么 SFINAE 需要 'Enable' 类模板参数?

(本题与C++11/C++14无关:示例使用C++03编译)enable_bool有成员(member)::type仅当T是booltemplatestructenable_bool{};templatestructenable_bool{typedefbooltype;};在下一个片段中,部分特化是正确的(参见gcc.godbolt.org)templatestructFoo{staticintbar(){return0;}};templatestructFoo::type>{staticintbar(){return1;}};intmain(){returnFoo::bar();}

带有 std::enable_if 的 C++ 可变参数模板部分模板特化

ITNOA我的问题是如何在可变参数模板部分模板特化场景中使用std::enable_if?例如,我有一个类使用如下所示的可变参数模板部分特化/***Commoncase.*/templatestructfoo;/***Finalsuperclassforfoo.*/templatestructfoo{voidfunc(){}};/***Regularfooclass.*/templatestructfoo:publicfoo{typedefsuperfoo;voidfunc(){coutsuper::templatefunc();}}它工作正常,但如果H是整数类型,我想要特定的部分特化

c++ - 如何从 C 风格转向 C++ 风格的 flex 解析器

我有典型的可重入C风格解析器,其中解析的数据包含在一个union中,如下所示:%union{intnumber;constchar*string;Item*item_ptr;}我想使用共享指针而不是普通指针。我不能使用std::shared_ptr因为我不能用C++11编译源代码,我也被禁止使用boost::shared_ptr。因此,我有自己的类SharedPtr,实现了所需的行为。不幸的是,我无法将SharedPtr类插入到union中,如下所示:%union{intnumber;constchar*string;SharedPtritem_ptr;}因为我收到以下错误:bison

c++ - 警告 : auto-importing has been activated without --enable-auto-import specified on the command line

我的环境:QtCreator2.3.1Qt4.7.4(32位)Windows7旗舰版(64位)尝试在QtforWindows中重建项目时,我遇到以下编译器警告:warning:auto-importinghasbeenactivatedwithout--enable-auto-importspecifiedonthecommandline.Thisshouldworkunlessitinvolvesconstantdatastructuresreferencingsymbolsfromauto-importedDLLs.发出此警告的项目包含一个DLL文件。尽管有警告,DLL中的类和函数

C++ - 通过 enable_if_t 推导参数包(可变参数模板)构造函数和复制构造函数

更新:谢谢你,大露营。这是最后的structA.structA{template>A(Args&&...args){cout,A>::value>>A(Arg&&arg){cout来源:关于这段代码,#include#include#includeusingnamespacestd;structA{template>,A>::value>>A(Args&&...args){cout输出是vvvvm在VC++14.0中。但是为什么输出不是vvccm?(我希望candd使用复制构造函数。而且我知道EffectiveModernC++Item27只使用一个转发引用。)

c++ - 使用 std::enable_if 作为函数参数与模板参数有什么区别?

我想知道使用std::enable_if有什么区别?作为函数参数还是模板参数?我有以下两个函数模板:#includetemplatevoidf_function(T,typenamestd::enable_if_t::value,int>=0){}template::value>>voidf_template(T){}intmain(){intx=1;f_function(x);f_template(x);}产生以下程序集(从https://godbolt.org/g/ON4Rya开始):main:pushq%rbpmovq%rsp,%rbpsubq$16,%rspmovl$1,-4(

c++ - 为继承 enable_shared_from_this 的类获取 unique_ptr

通常我更喜欢从工厂返回unique_ptr。最近我遇到了为继承enable_shared_from_this的类返回unique_ptr的问题。此类的用户可能会意外调用shared_from_this(),尽管它不属于任何shared_ptr,这会导致std::bad_weak_ptr异常(或C++17之前的未定义行为,通常作为异常实现)。代码的简单版本:classFoo:publicenable_shared_from_this{stringname;Foo(conststring&_name):name(_name){}public:staticunique_ptrcreate(c

c++ - 转发声明使用 enable_if : ambiguous call 的函数

我在声明一个使用boost::enable_if的函数时遇到了一些麻烦:下面的一段代码给我一个编译器错误://Declarationtemplatevoidfoo(Tt);//Definitiontemplatetypenameboost::enable_if>::typefoo(Tt){}intmain(){foo(12);return0;}编译时,出现“对foo的模糊调用”错误。根据enable_if的定义,'type'typedef在条件为真时对应于void,据我所知,的两个签名foo匹配。为什么编译器认为它们不同,是否有正确的方法来转发声明foo(最好不要重复enable_if

c++ - 警告 : non-static data member initializers only available with -std=c++11 or -std=gnu++11 [enabled by default]

这个问题在这里已经有了答案:C++ArrayInitializersWarnings(2个答案)关闭8年前。我刚刚在我的机器上安装了最新版本的cygwin和eclipseluna。它工作正常,我能够运行我的项目。但是,当我构建它们时,我收到了我不明白的警告。例如,这是我从“c++Primer”一书的网站上获得的头文件“Sales_item.h”的警告:warning:defaultedanddeletedfunctionsonlyavailablewith-std=c++11or-std=gnu++11[enabledbydefault]Sales_item()=default;^..