Python
Java
PHP
IOS
Android
Nodejs
JavaScript
Html5
Windows
Ubuntu
Linux
为什么不允许 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
如何构建一个在用作 constexpr(如断言)时行为不同的自定义宏?
从 C 14 开始 断言宏可以在函数中使用 即使它们被定义为 constexpr 我知道这与它的计算结果为 true 有关 但我无法弄清楚实际的代码是什么样子 具体来说 如何构建一个宏 该宏在运行时评估的 constexpr 函数中运行时打
c
macros
c14
assert
constexpr
C++ constexpr:在编译时计算 std 数组
我想转换一个 数组 bool到一个整数序列 所以我需要计算一个std array在编译时 这是我的代码 include
c
c14
variadictemplates
templatemetaprogramming
constexpr
保持函数参数的保守性
我正在使用整洁的 fmt 库 该库在其版本 8 中会在编译时检查其格式字符串 如果编译器支持相关功能 在某些时候 我想编写以下代码 throw my exception error 123 可悲的是 天真的实现 struct my exce
c
C20
constexpr
FMT
consteval
如何在编译时捕获递归函数的结果?
include
templates
recursion
c14
templatemetaprogramming
constexpr
C++20 constexpr 向量和字符串不起作用
我在尝试创建时遇到奇怪的编译器错误constexpr std string and std vector对象 include
c
visualc
C20
constexpr
stdstring
静态 constexpr 类成员何时需要类外定义?
我有以下 C 11 代码 简化版本 struct Info const char name int version class Base public const Info info Base Info info info info cla
c
C11
Plugins
constexpr
为什么在适用时不隐含 constexpr? [复制]
这个问题在这里已经有答案了 这些可能应该在不同的问题中 但它们是相关的 所以 为什么我们需要写constexpr根本吗 给定一组限制 编译器无法评估代码以查看它是否满足constexpr要求 并将其视为constexpr如果有的话 作为一个
c
C11
constexpr
将 struct 转换为 uint8_t 的 constexpr 数组
我需要从 constexpr 结构中创建 constexpr 字节数组 include
c
Arrays
templates
C17
constexpr
1
2
3
4
5
6
...9
»