array3.cpp:

- Qualify std::swap for compilers that don't have Koenig lookup

array5.cpp:
  - Don't use std::boolalpha, because it isn't portable


[SVN r12463]
This commit is contained in:
Douglas Gregor
2002-01-23 18:07:11 +00:00
parent f5699ae164
commit 09c271cf34
2 changed files with 4 additions and 3 deletions

View File

@ -17,7 +17,7 @@ int main()
// copy and change order // copy and change order
boost::array<std::string,4> seasons_orig = seasons; boost::array<std::string,4> seasons_orig = seasons;
for (unsigned i=seasons.size()-1; i>0; --i) { for (unsigned i=seasons.size()-1; i>0; --i) {
swap(seasons.at(i),seasons.at((i+1)%seasons.size())); std::swap(seasons.at(i),seasons.at((i+1)%seasons.size()));
} }
std::cout << "one way: "; std::cout << "one way: ";
@ -25,7 +25,7 @@ int main()
// try swap() // try swap()
std::cout << "other way: "; std::cout << "other way: ";
swap(seasons,seasons_orig); std::swap(seasons,seasons_orig);
print_elements(seasons); print_elements(seasons);
// try reverse iterators // try reverse iterators

View File

@ -27,7 +27,8 @@ int main()
// use some common STL container operations // use some common STL container operations
std::cout << "static_size: " << a.size() << std::endl; std::cout << "static_size: " << a.size() << std::endl;
std::cout << "size: " << a.size() << std::endl; std::cout << "size: " << a.size() << std::endl;
std::cout << "empty: " << std::boolalpha << a.empty() << std::endl; // Can't use std::boolalpha because it isn't portable
std::cout << "empty: " << (a.empty()? "true" : "false") << std::endl;
std::cout << "max_size: " << a.max_size() << std::endl; std::cout << "max_size: " << a.max_size() << std::endl;
std::cout << "front: " << a.front() << std::endl; std::cout << "front: " << a.front() << std::endl;
std::cout << "back: " << a.back() << std::endl; std::cout << "back: " << a.back() << std::endl;