C ++ std :: add_const,为什么该工具可以作为参考?

问题描述 投票:1回答:1

在cppreference中add_const可实现为

template< class T> struct add_const { typedef const T type; };

[当我尝试引用类型时,例如std::add_const<int&>,它是int&

我的问题是,由于int& const是非法的,为什么没有特定版本也可以参考?

c++ c++11
1个回答
0
投票

在C ++ 11标准的[dcl.ref] p1中,您具有:

© www.soinside.com 2019 - 2024. All rights reserved.