【发布时间】:2019-06-12 18:20:28
【问题描述】:
为什么constexpr 不能与std::cout 一起使用,但可以与printf 一起使用?
#include <iostream>
constexpr void f() { std::cout << ""; } //error
constexpr void g() { printf(""); } //ok
为什么std::cout 与 lambdas constexpr 一起使用?
#include <iostream>
int main () {
auto h = []() constexpr { std::cout << ""; }; //ok
}
【问题讨论】:
-
在 godbolt.org 上使用 gcc 9.1