扫码关注官方订阅号
为什么add_const对引用无效,比如我认为,add_const<int &>::type应该是const int &才对,而实际上,add_const<int &>::type仍旧是int &
闭关修行中......
引用只有底层const,没有顶层const。假如add_const<int &>对int &产生改变,则其type会是int &const,显然是不对的
template <typename T, bool = is_reference<T>::value || is_function<T>::value || is_const<T>::value > struct add_const;
然后写了true和false的特化
要加reference有一个add_lvalue_reference和add_rvalue_reference
add_lvalue_reference
add_rvalue_reference
微信扫码关注PHP中文网服务号
QQ扫码加入技术交流群
扫描下载App
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
PHP学习
技术支持
返回顶部
引用只有底层const,没有顶层const。
假如add_const<int &>对int &产生改变,则其type会是int &const,显然是不对的
然后写了true和false的特化
要加reference有一个
add_lvalue_reference
和add_rvalue_reference