Loading…
|
Translation changed |
|
|
String added in the repository |
|
Loading…
|
Translation changed |
|
|
String added in the repository |
|
Using the type checks with `static_assert` on function or class template types will provide users with helpful error messages and prevent undefined behaviors. This example shows how a template function which writes to a synchronous stream may check its argument:在函数或类模板类型上使用 `static_assert` 配合这些类型检查,可以给用户提供更清晰的错误信息,同时避免未定义行为。以下示例展示一个用于向同步流写入数据的模板函数,该示例演示如何对其参数类型进行检查: