gpt4 book ai didi

c++ - 这是什么类型的类模板定义?

转载 作者:行者123 更新时间:2023-11-30 01:40:25 25 4
gpt4 key购买 nike

template<class T> struct is_ref_wrapper<std::reference_wrapper<T>> : std::true_type {};

它出现在 possible implementation 中的 std::experimental::make_array .对我来说它看起来很奇怪的原因是类名包含一个模板参数列表 <std::reference_wrapper<T>>仅提及一个参数,但该参数位于类的模板参数内(即某些内容已被省略)。

最佳答案

您链接到的页面中的其他相关行是:

template<class> struct is_ref_wrapper : std::false_type {};

这定义了通用模板。下一行是专业。

template<class T> struct is_ref_wrapper<std::reference_wrapper<T>> : std::true_type {};

is_ref_wrapperstd::reference_wrapper<T> 实例化作为模板参数,使用特化。

关于c++ - 这是什么类型的类模板定义?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43396364/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com