Python
Java
PHP
IOS
Android
Nodejs
JavaScript
Html5
Windows
Ubuntu
Linux
const 和 constexpr 数组之间的区别
为什么有区别const and constexpr当与数组一起使用时 int const xs 1 2 3 constexpr int ys 1 2 3 int as xs 0 error int bs ys 0 fine 我希望两者都能x
c
Arrays
C11
constants
constexpr
在编译时使用 Constexpr 填充数组
我想使用 constexpr 填充枚举数组 数组的内容遵循一定的模式 我有一个枚举 将 ASCII 字符集分为四类 enum Type Alphabet Number Symbol Other constexpr Type table 12
c
templates
C11
constexpr
比较两个constexpr指针不是constexpr吗?
我正在寻找一种在编译时将类型映射到数值的方法 理想情况下不使用中建议的哈希this https stackoverflow com a 36122101 2173029 answer 由于指针可以是constexpr 我尝试过这个 stru
c
pointers
constexpr
为什么要为具有重要析构函数的类声明 constrexpr 构造函数(例如 unique_ptr、std::variant)
据我了解 至少对于c 14 析构函数不能是constexpr如果它不是微不足道的 隐式生成或 default 声明的意义何在constexpr具有非平凡析构函数的结构的构造函数 struct X int a constexpr X int
c
c14
constexpr
C17
了解左值到右值转换的示例
我很难理解这段代码 来自 C 14 草案标准的示例 转换拉瓦尔 调用未定义的行为g false 为什么constexpr使程序有效 另外 不访问 是什么意思 y n 在两次通话中g 我们正在返回n数据成员那么为什么最后一行说它不能访问它呢
c
languagelawyer
c14
constexpr
lvaluetorvalue
constexpr 函数及其参数
constexpr int hello int j return j 12 constexpr int bye int j 6 return j 12 int main int i 6 constexpr int a1 hello i er
c
constexpr
Constexpr 查找实现
回答后这个问题 https stackoverflow com questions 32395408 why arent stdalgorithms constexpr and which could be 32395481 3239625
c
c14
constexpr
C++ static constexpr 成员在类外重新声明
对于以下代码 为什么 main 中的第一个案例无需重新声明 Foo bar 就可以正常工作 而带有该函数的第二个案例则需要它 struct Foo static constexpr int bar 30 Declaration of Foo
c
struct
static
Definition
constexpr
为什么不允许 constexpr 局部变量作为默认函数参数?
我想我明白为什么 C 不允许local变量作为默认函数参数 int main auto local 1024 auto lambda auto arg1 local illegal use of local variable as defa
c
constexpr
defaultarguments
为什么使用成员数组而不是常量表达式调用 constexpr 函数?
我有以下辅助功能 template
c
templates
constexpr
“constexpr”函数的“noexcept”行为
的措辞 expr unary noexcept 改变于C 17 之前 n4140 5 3 7 noexcept 运算符 expr unary noexcept https timsong cpp github io cppwp n4140
c
C17
languagelawyer
constexpr
noexcept
在编译时通过 constexpr 或模板函数获取多维 std::array 的大小
我用的是三维std array 因为大小在编译时已知 但是 我注意到 size 函数不是静态的 因此 constexpr 模板函数无法访问 我已经找到了下面的演示示例 它估计一维的大小std array 然而 这不适用于二维或更多维度 有没
c
C11
templates
templatemetaprogramming
constexpr
为什么reinterpret_cast不是constexpr?
考虑以下片段 static constexpr uint8 t a 0 static constexpr const int8 t b reinterpret cast
c
C11
AVR
constexpr
reinterpretcast
编译器如何知道 C++ constexpr 计算不会触发未定义的行为?
C 标准mandates编译器要检查未定义的行为 in C constexpr 计算 In 这次演讲 https www youtube com watch v yG1OZ69H o Chandler Carruth 指出 在检查 UB 时
c
languagelawyer
undefinedbehavior
constexpr
为什么没有将 `std::initializer_list` 定义为文字类型?
这是这个问题的后续 声明 constexprinitializer list 对象是否合法 https stackoverflow com questions 16063123 is it legal to declare a conste
c
languagelawyer
c14
initializerlist
constexpr
类模板中的 Constexpr 成员函数
以下代码无法编译 template
c
C11
templates
constexpr
在常量表达式中调用“static constexpr”函数是...错误? [复制]
这个问题在这里已经有答案了 我有以下代码 class MyClass static constexpr bool foo return true void bar noexcept foo 我希望从那时起foo is a static co
c
C11
constexpr
noexcept
constantexpression
为什么 constexpr 静态成员(类型为类)需要定义?
gt 查看完整的代码片段和编译coliru http coliru stacked crooked com a e6ebe0ef8a87b601 我有一个文字类型 http en cppreference com w cpp concept
c
C11
staticmembers
c14
constexpr
浮点除以零而不是 constexpr
编译时 constexpr double x 123 0 constexpr double y x 0 0 std cout lt lt x lt lt 0 lt lt y lt lt n 编译器 gcc 4 9 2 std c 11 或
C11
c14
undefinedbehavior
constexpr
constexpr 函数何时在编译时进行求值?
既然声明为 constexpr 的函数有可能在运行时被调用 那么编译器根据什么标准决定是在编译时还是在运行时计算它呢 template
c
C11
Runtime
compiletime
constexpr
1
2
3
4
5
6
...9
»