⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 chapter9-37.cpp

📁 C++STL程序员开发指南
💻 CPP
字号:
//文件名:CHAPTER9-37.cpp
#include <set>
#include <iostream>
#if _MSC_VER > 1020   // if VC++ version is > 4.2
   using namespace std;  // std c++ libs implemented in std
#endif
void main( )
{
   set <int>::allocator_type s1_Alloc;
   set <int>::allocator_type s2_Alloc;
   set <double>::allocator_type s3_Alloc;
   set <int>::allocator_type s4_Alloc;
   // The following lines declare objectsthat use the default allocator.
   set <int> s1;
   set <int, allocator<int> > s2;
   set <double, allocator<double> > s3;
   s1_Alloc = s1.get_allocator( );
   s2_Alloc = s2.get_allocator( );
   s3_Alloc = s3.get_allocator( );
   cout << "The number of integers that can be allocated"
        << endl << "before free memory is exhausted: "<< s2.max_size( ) << "." << endl;
   cout << "\nThe number of doubles that can be allocated"
        << endl << "before free memory is exhausted: "<< s3.max_size( ) <<  "." << endl;
   // The following line creates a set s4 with the allocator of multiset s1.
   set <int> s4( less<int>( ), s1_Alloc );
   s4_Alloc = s4.get_allocator( );
   // Two allocators are interchangeable ifstorage allocated from each can be
   // deallocated by the other
   if( s1_Alloc == s4_Alloc )
   {
      cout << "\nThe allocators are interchangeable." << endl;
   }
   else
   {
      cout << "\nThe allocators are not interchangeable." << endl;
   }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -