//
Compliled in Code::Blocks,gcc
#include < vector >
#include < string >
#include < assert .h >
using std::basic_string;
using std::vector;
using std::string;
int main()
{
//true vector<bool>
basic_string<bool> visitedItems1;
visitedItems1.push_back(false);
visitedItems1.push_back(true);
assert(&visitedItems1[0]+sizeof(bool)==&visitedItems1[1]);
//basic_string is not a reference counting class..sounds strange
basic_string<bool> another(visitedItems1);
assert(another.begin()!=visitedItems1.begin());
//basic_string surely not a reference counting class in this IDE
string s1="abc";
string s2(s1);
string s3=s1;
string s4(s1.begin(),s1.end());
assert(s1.begin()!=s2.begin());
assert(s1.begin()!=s3.begin());
assert(s1.begin()!=s4.begin());
//vector<bit> in fact
vector<bool> visitedItems2;
visitedItems2.push_back(false);
visitedItems2.push_back(true);
assert(&visitedItems2[0]+sizeof(bool)!=&visitedItems2[1]);
system("pause");
return 0;
//However,according to effecitve STL,deque<bool> and bitset(non-standard)
//would be better choices if you'd like to use vector<bool> that
//act like a vector
}
#include < vector >
#include < string >
#include < assert .h >
using std::basic_string;
using std::vector;
using std::string;
int main()
{
//true vector<bool>
basic_string<bool> visitedItems1;
visitedItems1.push_back(false);
visitedItems1.push_back(true);
assert(&visitedItems1[0]+sizeof(bool)==&visitedItems1[1]);
//basic_string is not a reference counting class..sounds strange
basic_string<bool> another(visitedItems1);
assert(another.begin()!=visitedItems1.begin());
//basic_string surely not a reference counting class in this IDE
string s1="abc";
string s2(s1);
string s3=s1;
string s4(s1.begin(),s1.end());
assert(s1.begin()!=s2.begin());
assert(s1.begin()!=s3.begin());
assert(s1.begin()!=s4.begin());
//vector<bit> in fact
vector<bool> visitedItems2;
visitedItems2.push_back(false);
visitedItems2.push_back(true);
assert(&visitedItems2[0]+sizeof(bool)!=&visitedItems2[1]);
system("pause");
return 0;
//However,according to effecitve STL,deque<bool> and bitset(non-standard)
//would be better choices if you'd like to use vector<bool> that
//act like a vector
}