草庐IT

uvm_declare_p_sequencer

全部标签

c++ - 如何访问 integer_sequence 的第 n 个值?

这个问题在这里已经有了答案:templateparameterpacksaccessNthtypeandNthelement(5个回答)2年前关闭。我想知道如何访问std::integer_sequence的第n个值.例如给定一个类型usingfoo=std::integer_sequence;我想要类似的东西autoi=get();//i=4标准库中有什么东西可以做到这一点吗?如果不是,如果我希望它在C++14(而不是C++17)中工作,我是否需要求助于迭代解决方案? 最佳答案 据我所知,没有这样的内置方法,但您可以自己用几行简洁

c++ - 拆分 std::index_sequence 时出错

我正在尝试将index_sequence分成两半。为此,我生成了一个包含下半部分的index_sequence,并使用它来跳过完整index_sequence中的前导元素。以下是代表我要实现的目标的最小测试用例:templatestructindex_sequence{};templatevoidfoo(index_sequence,index_sequence){}intmain(){foo(index_sequence{},index_sequence{});}我已经用最新版本的Clang、GCC和MSVC试过了,它们都无法推断出J...。这是标准允许的吗?如果不是,为什么以及什么

python - "Error: '::hypot ' has not been declared"在 cmath 中尝试嵌入 Python

在尝试使用#include将Python嵌入我的程序时遇到一些问题之后,我终于找到了所有正确的库,但我还有另一个错误。当我尝试使用#include进行编译时它会将我重定向到code::blocks目录中的cmath,并在显示using::hypot;的行放置一个错误标记并说:error:'::hypot'hasnotbeendeclared.我不知道为什么这是一个错误,特别是因为我的code::blocks安装时出现了这个错误,并且出现了,我想是因为Python试图包含它。我在Windows上,使用的是最新版本的Python(3.4.2) 最佳答案

c++ - 错误 : forward declaration of struct

我收到错误:proprietario.cpp:36:error:invaliduseofincompletetype‘structMotocicleta’proprietario.h:12:error:forwarddeclarationof‘structMotocicleta’摩托车.h:#ifndef__MOTOCICLETA__#define__MOTOCICLETA__#include#include"veiculo.h"#include"proprietario.h"usingnamespacestd;classProprietario;classMotocicleta:pu

c++ - 模板特化 : does not match any template declaration

我在学习模板特化的时候,用了一个很简单的例子,但是还是报错。#includetemplateclasschrrr{public:Tchgchr(Tc);};templateTchrrr::chgchr(Tc){returnc+1;}templateclasschrrr{public:charchgchr(charc);};templatecharchrrr::chgchr(charc){returnc+2;}usingnamespacestd;intmain(){chara='a';inti=1;chrrrit;chrrrch;cout错误说:line20:error:template

c++ - 如何在编译时找出 integer_sequence 是否包含给定的数字?

给定:typedefstd::integer_sequenceallowed_args_t;和:templatevoidfoo(){static_assert(/*fireifargnotinallowed_args_t!*/)}我应该如何编写static_assert以使其在编译时尽可能便宜?我正在使用C++17。 最佳答案 你可能想使用:templateconstexprboolis_in(inti,std::integer_sequence){return((i==Is)||...);}typedefstd::integer_

C++ 零规则 & 什么是 "user-declared"构造函数?

根据LightnessRacesinOrbit的说明,我缩小了我的帖子范围。看完这篇文章:TheRuleofZero,我明白了最多,但我还是想解决一些我遇到的不明白的问题:1.看这个短语:IfthedefinitionofaclassXdoesnotexplicitlydeclareamoveconstructor,onewillbeimplicitlydeclaredasdefaultedifandonlyif:Xdoesnothaveauser-declaredcopyconstructor,andXdoesnothaveauser-declaredcopyassignmentop

C++ 内联函数 : declare as such, 是这样定义的,还是两者都定义?为什么?

以下代码段编译没有问题,即使foo被定义为内联但未声明为内联,bar被声明为内联但未定义为内联。intfoo();inlineintfoo(){return3;}inlineintbar();intbar(){return4;}inlineintfoobar();inlineintfoobar(){return5;}intmain(){//...}我的第一个问题:编译器是否将foo读取为内联?bar呢?这是C++标准规定的吗?我的第二个问题:以下哪一个是声明和定义内联函数的最佳实践?是foo吗?酒吧?还是foobar?为什么?inb4我阅读了一些与此相关的其他帖子,但没有一个直接回答我

java - 在 C、C++ 和 Java 中提升/重新排序 : Must variable declarations always be on top in a context?

我读了一点hoistingandreordering,所以看起来JavaVM可能会选择提升一些表达式。我还阅读了有关在Javascript中提升函数声明的信息。第一个问题:有人可以确认提升是否通常存在于C、C++和Java中?还是它们都依赖于编译器/优化?我读了很多示例C代码,这些代码总是将变量声明放在顶部,在任何断言或边界条件之前。我认为在变量声明之前完成所有断言和边界情况会更快一些,因为函数可以终止。主要问题:变量声明必须始终在上下文中位于最前面吗?(这里有提升吗?)还是编译器通过首先检查这些独立的断言和边界情况(在不相关的变量声明之前)来自动优化代码?这是一个相关的例子:void

c++ - Qt 5 : unable to declare signal that takes rvalue reference

可能我遗漏了什么,但我找不到任何信号不能采用右值引用的信息。所以,我有一个包含以下信号声明的类:signals:voidmessageDecoded(HTDataMsg&&msg);当我尝试编译它时,出现错误:moc_htcodec.cpp:Instaticmemberfunction‘staticvoidHTCodec::qt_static_metacall(QObject*,QMetaObject::Call,int,void**)’:moc_htcodec.cpp:71:77:error:cannotbind‘HTDataMsg’lvalueto‘HTDataMsg&&’case