为什么add_const对引用无效,比如我认为,add_const<int &>::type应该是const int &才对,而实际上,add_const<int &>::type仍旧是int &
闭关修行中......
References only have underlying const, not top-level const. If add_const<int &> changes int &, its type will be int &const, which is obviously wrong
template <typename T, bool = is_reference<T>::value || is_function<T>::value || is_const<T>::value > struct add_const;
Then I wrote specializations of true and false
To add a reference, there are one add_lvalue_reference and add_rvalue_reference
add_lvalue_reference
add_rvalue_reference
References only have underlying const, not top-level const.
If add_const<int &> changes int &, its type will be int &const, which is obviously wrong
Then I wrote specializations of true and false
To add a reference, there are one
add_lvalue_reference
andadd_rvalue_reference