c++ 11 practise -1-

c++ 11 practise -1-

2013-04-12 11:09AM

#include <iostream>
#include <array>
#include <forward_list>
#include <string>
#include <unordered_set>
using namespace std;

int main()
{
    array<int, 3> arr;
    get<0>(arr) = 1;
    get<1>(arr) = 2;
    get<2>(arr) = 3;
    cout << "(" << get<0>(arr) << get<1>(arr) << get<2>(arr) << ")" << endl;

    // forward_list
    forward_list<string> words1;// {"the", "greatest", "country", "in", "the", "world"};
    words1.push_front("the");
    words1.push_front("greatest");
    words1.push_front("salesman");
    words1.push_front("in");
    words1.push_front("the");
    words1.push_front("world");

    long double f = 23.43;
    cout << to_string(f) << endl;
    for(auto ci = words1.begin(); ci != words1.end(); ++ci)
        cout << *ci << " ";
    cout << endl;
    forward_list<string> words2(words1.begin(), words1.end());
    forward_list<string> words3(words1);
    //forward_list<string> words4 (words1.size(), "Mo");

    // unordered_set
    // set,map : based on 
    unordered_set<int> set1;
    set1.insert(343);
    set1.insert(3);
    set1.insert(34);
    set1.insert(43);
    set1.insert(33);
    set1.insert(443);
    auto d = set1.find(43);
    if(d != set1.end())
        cout << "find it" << endl;
    return 0;
}
posted on 2013-04-12 11:08  SunWentao  阅读(264)  评论(0编辑  收藏  举报