set-max_size

////////////////////////////////////////
//      2018/04/29 8:14:44
//      set-max_size

// the maximun number of elements that the set can hold
#include <iostream>
#include <set>
#include <algorithm>
#include <iterator>

using namespace std;

void print(set<int, less<int>> s){
    copy(s.begin(),s.end(), ostream_iterator<int>(cout, " "));
    cout << endl;
}

//=============================
int main(){
    int ary[] = { 1, 2, 3, 2, 3, 4, 8, 2, 5, 6 };
    set<int, less<int>> s;

    s.insert(ary, ary + 10);
    print(s);

    cout << "size of  's' = " << s.size() << endl;
    cout << "max_size of  's' = " << s.max_size() << endl;

    return 0;
}


/*
OUTPUT:
    1 2 3 4 5 6 8
    size of  's' = 7
    max_size of  's' = 214748364
*/ 
原文地址:https://www.cnblogs.com/laohaozi/p/12537900.html