- #include <boost/foreach.hpp>
- #include <string>
- #include <iostream>
- #include <vector>
- #include <list>
- #include <deque>
- #include <boost/array.hpp>
- int main(int argc,char* argv[])
- {
- std::string test = "hello";
- BOOST_FOREACH(char it,test)
- {
- std::cout<<it<<std::endl;
- }
- int int_array[] = {1,1,2,3,5,6,6,7,9};
- BOOST_FOREACH(int i, int_array)
- {
- std::cout<<i<<std::endl;
- }
- std::vector<std::string> str_vector;
- str_vector.push_back("hello,C++");
- str_vector.push_back("boost foreach");
- BOOST_FOREACH(std::string iter, str_vector)
- {
- std::cout<<iter<<std::endl;
- }
- boost::array<std::string,3> str_array;
- str_array[0] = "this is way";
- str_array[1] = "please my love";
- BOOST_FOREACH(std::string iter, str_array)
- {
- std::cout<<iter<<std::endl;
- }
- return 0;
- }
boost foreach库的例子
最新推荐文章于 2023-08-23 03:56:12 发布