Re: [問題] 一個有意思的問題 vector <const int>
用 type-trait 看了一下:
using std::cout;
using std::endl;
using std::vector;
template< typename T >
struct Type {
private:
template< typename U >
struct UnConst {
typedef U Result;
enum { isConst = 0 };
};
template< typename U >
struct UnConst< const U > {
typedef U Result;
enum { isConst = 1 };
};
template< typename U >
struct UnConst< const U & > {
typedef U & Result;
enum { isConst = 1 };
};
public:
typedef typename UnConst< T >::Result NonConstType;
enum { isConst = UnConst< T >::isConst };
};
int main() {
cout << Type< vector< const int >::value_type >::isConst << endl;
return 0;
}
結論是 VC 會自己把 template 去 const ... 吧
--
自High筆記(半荒廢)
http://legnaleurc.blogspot.com/
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 123.205.248.119
→
12/20 14:41, , 1F
12/20 14:41, 1F
討論串 (同標題文章)