Python
Java
PHP
IOS
Android
Nodejs
JavaScript
Html5
Windows
Ubuntu
Linux
在 C++ 中模拟编译时反射
我有以下结构 struct Data std string firstMember std string secondMember std string thirdMember 我想按字符串名称选择其中一个成员constexpr方式 比如
c
constexpr
const 和 constexpr 最终会是同一件事吗?
我刚刚读了答案 变量上的 const 与 constexpr https stackoverflow com q 13346879 1593077 我正在看这个Google Tech 谈论 C 11 14 功能 https www yout
c
C11
constants
constexpr
compiletimeconstant
使用 C++17 Constexpr 查找数组
我正在尝试编写一个 constexpr find 函数 它将返回包含特定值的 std array 的索引 下面的函数似乎工作正常 除非包含的类型是const char include
c
Arrays
C17
constexpr
constexpr 比 const 更“恒定”吗?
C 编程语言第四版 Bjarne Stroustrup 强调我的 2 2 3 常数 在一些地方 语言规则需要常量表达式 例如 数组边界 2 2 5 7 3 大小写标签 2 2 4 9 4 2 一些 模板参数 第 25 2 节 和使用 con
c
C11
constants
immutability
constexpr
为什么引用不能与编译时函数一起使用?
我有两个片段 第一个片段 include
c
C17
constexpr
compiletime
constantexpression
为什么 `std::invoke` 不是 constexpr?
不应该std 调用 http en cppreference com w cpp utility functional invoke be constexpr尤其是之后C 17 中的 constexpr lambda http en cpp
c
std
invoke
constexpr
C17
如何使用 std::copy 将 constexpr 数组复制到另一个 constexpr 数组?
在下面的代码中 我创建了一个长度为 6 的数组 并在前 3 个元素中使用 1 2 和 3 对其进行初始化 然后我将前 3 个元素复制到后 3 个元素 然后我按顺序打印所有元素 std array
c
Arrays
Algorithm
C11
constexpr
constexpr 函数作为数组大小
我试图找出为什么我的代码可以编译 但它不应该编译 include
c
C11
constexpr
constexpr 中的“整数常量溢出”警告
我正在尝试找到一个与 constexpr 兼容的哈希函数 用于在编译时对字符串进行哈希处理 字符串的数量非常少 static constexpr unsigned int Fnv1aBasis 0x811C9DC5 static const
c
C11
visualstudio2015
constexpr
添加“constexpr”可以改变行为吗?
给定两个程序 源代码中唯一的区别是其中一个的存在或不存在constexpr 有没有可能程序的含义发生了变化 换句话说 如果有一个编译器选项要求编译器努力推断constexpr在可能的情况下 它会破坏现有的标准代码和 或以不好的方式改变其含义
c
C11
constexpr
使用 consteval 代替 constexpr 函数有哪些优点?
我知道需求的差异 我最感兴趣的是它带来的代码质量带来的好处 我能想到的几件事 读者只需阅读函数签名即可知道该函数是在编译时评估的 编译器可能会发出更少的代码 因为constevalfns 在运行时从不使用 这是推测 我没有这方面的真实数据
c
constexpr
C20
consteval
gcc 如何在 constexpr 上下文中编译 C 函数?
鉴于C 标准库 当前 不提供 cmath 函数的 constexpr 版本 https stackoverflow com questions 42189190 why doesnt the c standard library provi
c
gcc
visualc
Clang
constexpr
编译时的模板和 constexpr 推导取决于编译器和优化标志
以下问题是从更大的代码浓缩而来的 因此 有些表达式看似多余或不必要 但对原始代码至关重要 考虑有一个结构体 其中包含编译时常量和一个简单的容器类 template
c
templates
C11
CUDA
constexpr
我们可以在 constexpr 函数中省略局部变量的 const 吗?
例如 constexpr int g return 30 constexpr int f Can we omit const const int x g const int y 10 return x y 有没有任何一点到永远在 a 中声明
c
C11
constants
c14
constexpr
static_casting 的结果是 constexpr void* 常量表达式吗?
clang 拒绝 gcc 允许的这段代码 int main static constexpr const void vp nullptr static constexpr const char cp static cast
c
Clang
languagelawyer
c14
constexpr
constexpr 的函数参数等效项是什么?
我们正在尝试加速 Clang 和 Visual C 下的一些代码 GCC 和 ICC 也可以 我们thought我们可以使用constexpr告诉 Clang 一个值是一个编译时常量 但它会导致编译错误 clang g2 O3 std c
C11
Clang
constexpr
我可以重新解释 constexpr 函数的参数吗?
我想编写一个在编译时求值的函数 它需要一个指向 4 字节数组的指针 并输出一个与该数组具有相同位模式的 int 所以我想出了 constexpr int f const char p return reinterpret cast
c
compilererrors
BitManipulation
C17
constexpr
链接器错误(未定义的引用)与“static constexpr const char*”和完美转发[重复]
这个问题在这里已经有答案了 include
c
Linker
c14
constexpr
perfectforwarding
按值传递的整数常量,被视为 constexpr?
尽管我以前使用过这样的代码 并且很明显编译器有足够的信息可以工作 但我不太明白为什么要编译 template
c
templates
c14
constexpr
如何在 constexpr 函数中拥有临时变量?
这是我想做的简化版本 constexpr float f float a float b constexpr float temp a b return temp temp temp 在我的版本中 a b 是更复杂的东西 所以我不想将其剪切
c
constexpr
«
1
2
3
4
5
6
7
8
9
»