Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

第 126 期的编译期动态分配代码示例 #68

Closed
fanenr opened this issue Aug 22, 2023 · 1 comment
Closed

第 126 期的编译期动态分配代码示例 #68

fanenr opened this issue Aug 22, 2023 · 1 comment

Comments

@fanenr
Copy link

fanenr commented Aug 22, 2023

位置

https://github.com/wanghenshui/cppweeklynews/blob/dev/posts/126.md#c20-dynamic-allocations-at-compile-time

问题

我看了一下原文,原文是最后将 Calc 标识为 constexpr,然后用 as_constant 函数强制这个 constexpr 函数在编译期计算。

您的原文中,将 Calc 函数标识为 consteval,后面加不加 as_constant 都会强制编译期计算。而且,res 本身是一个 run-time 变量,再作为参数调用 Calc 是百分百失败的。

我猜测是您笔误,将 Calc 函数标记错了?

@fanenr fanenr changed the title 第 126 期的编译期动态内存分配代码 第 126 期的编译期动态分配代码示例 Aug 22, 2023
@wanghenshui
Copy link
Owner

你说的对,抄错了

wanghenshui added a commit that referenced this issue Aug 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants