다음을 통해 공유


set::value_type

A type that describes an object stored as an element of a set in its capacity as a value.

typedef Key value_type;

설명

value_type is a synonym for the template parameter Key.

For more information on Key, see the Remarks section of the set 클래스 topic.

Note that both key_type and value_type are synonyms for the template parameter Key. Both types are provided for the set and multiset classes, where they are identical, for compatibility with the map and multimap classes, where they are distinct.

예제

// set_value_type.cpp
// compile with: /EHsc
#include <set>
#include <iostream>

int main( )
{
   using namespace std;
   set <int> s1;
   set <int>::iterator s1_Iter;

   set <int>::value_type svt_Int;   // Declare value_type
   svt_Int = 10;            // Initialize value_type

   set <int> :: key_type skt_Int;   // Declare key_type
   skt_Int = 20;             // Initialize key_type

   s1.insert( svt_Int );         // Insert value into s1
   s1.insert( skt_Int );         // Insert key into s1

   // A set accepts key_types or value_types as elements
   cout << "The set has elements:";
   for ( s1_Iter = s1.begin( ) ; s1_Iter != s1.end( ); s1_Iter++)
      cout << " " << *s1_Iter;
   cout << "." << endl;
}
  

요구 사항

헤더: <설정>

네임스페이스: std

참고 항목

참조

set 클래스

표준 템플릿 라이브러리