c++ - std::array 的实现
问题描述
我正在查看 MSVC 的 std::array 实现并看到了这个:
#if _HAS_CXX17
template <class _First, class... _Rest>
struct _Enforce_same {
static_assert(conjunction_v<is_same<_First, _Rest>...>,
"N4687 26.3.7.2 [array.cons]/2: "
"Requires: (is_same_v<T, U> && ...) is true. Otherwise the program is ill-formed.");
using type = _First;
};
template <class _First, class... _Rest>
array(_First, _Rest...)->array<typename _Enforce_same<_First, _Rest...>::type, 1 + sizeof...(_Rest)>;
#endif // _HAS_CXX17
第二件事是如何工作的?它看起来不像一个类或函数,那么它是什么?
解决方案
推荐阅读
- javascript - 反应:TypeError:this.props.update 不是函数
- flutter - 使用 BLoC 从 ListView 更改为 GridView
- string - 查找满足给定顺序的唯一字符的字典最小字符串的算法
- jquery - 我正在尝试在 Codeignitor 中调用 Ajax,但它不起作用
- json - 动态添加绑定所需标签 go-gin
- java - 来自 camunda UserTask 的挂钩事件
- python - 在python中为预测值添加误差线
- android - 如何将字符串数据从活动发送到片段?
- mysql - 带有分页的自定义查询在 Spring Boot JPA 存储库中不起作用
- reactjs - REACT 应用程序未在命令提示符下启动\