【发布时间】:2015-12-18 05:40:51
【问题描述】:
我有以下代码编译得很好:
void foo::bar(const vector<int> arg) {
int* ptr = arg.data();
// do something with ptr
}
我需要为vector<bool>重载这个函数
void foo::bar(const vector<bool> arg) {
int* ptr = arg.data();
// error C2039: 'data': is not a member ofstd::vector<bool,std::allocator<_Ty>>'
// do something with ptr
}
vector<bool> 没有data() 成员的原因是什么?
在这里 (en.cppreference.com) 我没有找到特定于 bool 的 std::vector 的情况。
代码使用 MSVS 2015 编译。
【问题讨论】:
-
查找here
标签: c++ c++11 visual-studio-2015 std stdvector