<cliext/utility> (STL/CLR)

클래스 템플릿 및 여러 지원 함수 템플릿 pair 을 정의하려면 STL/CLR 헤더 <cliext/utility> 를 포함합니다.

구문

#include <cliext/utility>

요구 사항

헤더:<cliext/utility>

네임스페이스:cliext

선언

클래스 설명
pair 요소 쌍을 래핑합니다.
연산자 설명
operator== (pair) pair 같음 비교입니다.
operator!= (pair) pair 비교가 같지 않습니다.
operator< (pair) pair 보다 작습니다.
operator<= (pair) pair 보다 작거나 같은 비교입니다.
operator> (pair) pair 비교보다 큼.
operator>= (pair) pair 보다 크거나 같은 비교입니다.
함수 설명
make_pair pair 값 쌍에서 만듭니다.

pair

템플릿 클래스는 값 쌍을 래핑하는 개체를 설명합니다.

구문

template<typename Value1,
    typename Value2>
    ref class pair;

매개 변수

Value1
첫 번째 래핑된 값의 형식입니다.

Value2
두 번째 래핑된 값의 형식입니다.

멤버

형식 정의 설명
pair::first_type 첫 번째 래핑된 값의 형식입니다.
pair::second_type 두 번째 래핑된 값의 형식입니다.
Member 개체 설명
pair::first 첫 번째 저장된 값입니다.
pair::second 두 번째 저장된 값입니다.
멤버 함수 설명
pair::pair pair 개체를 생성합니다.
pair::swap pair 개체의 내용을 바꿉니다.
연산자 설명
pair::operator= 저장된 값 쌍을 바꿉니다.

설명

개체는 값 쌍을 저장합니다. 이 템플릿 클래스를 사용하여 두 값을 단일 개체로 결합합니다. 또한 여기에 설명된 개체 cliext::pair 는 관리되는 형식만 저장합니다. 관리되지 않는 형식 쌍을 저장 std::pair하려면 에 선언되어 있습니다 <utility>.

pair::first

첫 번째 래핑된 값입니다.

구문

Value1 first;

설명

개체는 첫 번째 래핑된 값을 저장합니다.

예시

// cliext_pair_first.cpp
// compile with: /clr
#include <cliext/utility>

int main()
    {
    cliext::pair<wchar_t, int> c1(L'x', 3);
    System::Console::WriteLine("[{0}, {1}]", c1.first, c1.second);

    cliext::pair<wchar_t, int>::first_type first_val = c1.first;
    cliext::pair<wchar_t, int>::second_type second_val = c1.second;
    System::Console::WriteLine("[{0}, {1}]", first_val, second_val);
    return (0);
    }
[x, 3]

pair::first_type

첫 번째 래핑된 값의 형식입니다.

구문

typedef Value1 first_type;

설명

이 형식은 템플릿 매개 변수 Value1의 동의어입니다.

예시

// cliext_pair_first_type.cpp
// compile with: /clr
#include <cliext/utility>

int main()
    {
    cliext::pair<wchar_t, int> c1(L'x', 3);
    System::Console::WriteLine("[{0}, {1}]", c1.first, c1.second);

    cliext::pair<wchar_t, int>::first_type first_val = c1.first;
    cliext::pair<wchar_t, int>::second_type second_val = c1.second;
    System::Console::WriteLine("[{0}, {1}]", first_val, second_val);
    return (0);
    }
[x, 3]

pair::operator=

저장된 값 쌍을 바꿉니다.

구문

pair<Value1, Value2>% operator=(pair<Value1, Value2>% right);

매개 변수

right
pair 복사할 수 있습니다.

설명

멤버 연산자는 개체에 복사한 다음 반환합니다 right*this. 저장된 값 쌍을 저장된 값 right쌍의 복사본으로 바꾸는 데 사용합니다.

예시

// cliext_pair_operator_as.cpp
// compile with: /clr
#include <cliext/utility>

int main()
    {
    cliext::pair<wchar_t, int> c1(L'x', 3);
    System::Console::WriteLine("[{0}, {1}]", c1.first, c1.second);

// assign to a new pair
    cliext::pair<wchar_t, int> c2;
    c2 = c1;
    System::Console::WriteLine("[{0}, {1}]", c2.first, c2.second);
    return (0);
    }
[x, 3]
[x, 3]

pair::pair

pair 개체를 생성합니다.

구문

pair();
pair(pair<Coll>% right);
pair(pair<Coll>^ right);
pair(Value1 val1, Value2 val2);

매개 변수

right
pair 저장합니다.

val1
저장할 첫 번째 값입니다.

val2
저장할 두 번째 값입니다.

설명

생성자:

pair();

는 기본 생성 값을 사용하여 저장된 쌍을 초기화합니다.

생성자:

pair(pair<Value1, Value2>% right);

와 함께 저장된 쌍을 right.first 초기화합니다 right.second.

pair(pair<Value1, Value2>^ right);

와 함께 저장된 쌍을 right->first 초기화합니다 right->second.

생성자:

pair(Value1 val1, Value2 val2);

와 함께 저장된 쌍을 val1 초기화합니다 val2.

예시

// cliext_pair_construct.cpp
// compile with: /clr
#include <cliext/utility>

int main()
    {
// construct an empty container
    cliext::pair<wchar_t, int> c1;
    System::Console::WriteLine("[{0}, {1}]",
        c1.first == L'\0' ? "\\0" : "??", c1.second);

// construct with a pair of values
    cliext::pair<wchar_t, int> c2(L'x', 3);
    System::Console::WriteLine("[{0}, {1}]", c2.first, c2.second);

// construct by copying another pair
    cliext::pair<wchar_t, int> c3(c2);
    System::Console::WriteLine("[{0}, {1}]", c3.first, c3.second);

// construct by copying a pair handle
    cliext::pair<wchar_t, int> c4(%c3);
    System::Console::WriteLine("[{0}, {1}]", c4.first, c4.second);

    return (0);
    }
[\0, 0]
[x, 3]
[x, 3]
[x, 3]

pair::second

두 번째 래핑된 값입니다.

구문

Value2 second;

설명

개체는 두 번째 래핑된 값을 저장합니다.

예시

// cliext_pair_second.cpp
// compile with: /clr
#include <cliext/utility>

int main()
    {
    cliext::pair<wchar_t, int> c1(L'x', 3);
    System::Console::WriteLine("[{0}, {1}]", c1.first, c1.second);

    cliext::pair<wchar_t, int>::first_type first_val = c1.first;
    cliext::pair<wchar_t, int>::second_type second_val = c1.second;
    System::Console::WriteLine("[{0}, {1}]", first_val, second_val);
    return (0);
    }
[x, 3]

pair::second_type

두 번째 래핑된 값의 형식입니다.

구문

typedef Value2 second_type;

설명

이 형식은 템플릿 매개 변수 Value2의 동의어입니다.

예시

// cliext_pair_second_type.cpp
// compile with: /clr
#include <cliext/utility>

int main()
    {
    cliext::pair<wchar_t, int> c1(L'x', 3);
    System::Console::WriteLine("[{0}, {1}]", c1.first, c1.second);

    cliext::pair<wchar_t, int>::first_type first_val = c1.first;
    cliext::pair<wchar_t, int>::second_type second_val = c1.second;
    System::Console::WriteLine("[{0}, {1}]", first_val, second_val);
    return (0);
    }
[x, 3]

pair::swap

pair 개체의 내용을 바꿉니다.

구문

void swap(pair<Value1, Value2>% right);

매개 변수

right
pair 을 사용하여 콘텐츠를 교환합니다.

설명

멤버 함수는 저장된 값 쌍을 간에 *this 교환합니다 right.

예시

// cliext_pair_swap.cpp
// compile with: /clr
#include <cliext/adapter>
#include <cliext/deque>

typedef cliext::collection_adapter<
    System::Collections::ICollection> Mycoll;
int main()
    {
    cliext::deque<wchar_t> d1;
    d1.push_back(L'a');
    d1.push_back(L'b');
    d1.push_back(L'c');
    Mycoll c1(%d1);

// display initial contents " a b c"
    for each (wchar_t elem in c1)
        System::Console::Write("{0} ", elem);
    System::Console::WriteLine();

// construct another container with repetition of values
    cliext::deque<wchar_t> d2(5, L'x');
    Mycoll c2(%d2);
    for each (wchar_t elem in c2)
        System::Console::Write("{0} ", elem);
    System::Console::WriteLine();

// swap and redisplay
    c1.swap(c2);
    for each (wchar_t elem in c1)
        System::Console::Write("{0} ", elem);
    System::Console::WriteLine();

    for each (wchar_t elem in c2)
        System::Console::Write("{0} ", elem);
    System::Console::WriteLine();
    return (0);
    }
a b c
x x x x x
x x x x x
a b c

make_pair

pair 값 쌍에서 만듭니다.

구문

template<typename Value1,
    typename Value2>
    pair<Value1, Value2> make_pair(Value1 first, Value2 second);

매개 변수

Value1
첫 번째 래핑된 값의 형식입니다.

Value2
두 번째 래핑된 값의 형식입니다.

first
래핑할 첫 번째 값입니다.

second
래핑할 두 번째 값입니다.

설명

함수 템플릿은 .를 반환합니다 pair<Value1, Value2>(first, second). 이 값을 사용하여 값 쌍에서 개체를 생성 pair<Value1, Value2> 합니다.

예시

// cliext_make_pair.cpp
// compile with: /clr
#include <cliext/utility>

int main()
    {
    cliext::pair<wchar_t, int> c1(L'x', 3);
    System::Console::WriteLine("[{0}, {1}]", c1.first, c1.second);

    c1 = cliext::make_pair(L'y', 4);
    System::Console::WriteLine("[{0}, {1}]", c1.first, c1.second);
    return (0);
    }
[x, 3]
[y, 4]

operator!= (pair)

pair 비교가 같지 않습니다.

구문

template<typename Value1,
    typename Value2>
    bool operator!=(pair<Value1, Value2>% left,
        pair<Value1, Value2>% right);

매개 변수

left
비교할 왼쪽 pair 입니다.

right
비교할 권리 pair 입니다.

설명

연산자 함수는 .를 반환합니다 !(left == right). 두 개체가 요소별로 비교될 때 pairright 같은 순서가 지정되지 않았는지 여부를 left 테스트하는 데 사용합니다.

예시

// cliext_pair_operator_ne.cpp
// compile with: /clr
#include <cliext/utility>

int main()
    {
    cliext::pair<wchar_t, int> c1(L'x', 3);
    System::Console::WriteLine("[{0}, {1}]", c1.first, c1.second);
    cliext::pair<wchar_t, int> c2(L'x', 4);
    System::Console::WriteLine("[{0}, {1}]", c2.first, c2.second);

    System::Console::WriteLine("[x 3] != [x 3] is {0}",
        c1 != c1);
    System::Console::WriteLine("[x 3] != [x 4] is {0}",
        c1 != c2);
    return (0);
    }
[x, 3]
[x, 4]
[x 3] != [x 3] is False
[x 3] != [x 4] is True

operator<

pair 보다 작습니다.

구문

template<typename Value1,
    typename Value2>
    bool operator<(pair<Value1, Value2>% left,
        pair<Value1, Value2>% right);

매개 변수

left
비교할 왼쪽 pair 입니다.

right
비교할 권리 pair 입니다.

설명

연산자 함수는 .를 반환합니다 left.first < right.first || !(right.first < left.first && left.second < right.second. 두 개체가 요소별로 비교될 때 pair 이전 right 순서가 지정되었는지 여부를 left 테스트하는 데 사용합니다.

예시

// cliext_pair_operator_lt.cpp
// compile with: /clr
#include <cliext/utility>

int main()
    {
    cliext::pair<wchar_t, int> c1(L'x', 3);
    System::Console::WriteLine("[{0}, {1}]", c1.first, c1.second);
    cliext::pair<wchar_t, int> c2(L'x', 4);
    System::Console::WriteLine("[{0}, {1}]", c2.first, c2.second);

    System::Console::WriteLine("[x 3] < [x 3] is {0}",
        c1 < c1);
    System::Console::WriteLine("[x 3] < [x 4] is {0}",
        c1 < c2);
    return (0);
    }
[x, 3]
[x, 4]
[x 3] < [x 3] is False
[x 3] < [x 4] is True

operator<=

pair 보다 작거나 같은 비교입니다.

구문

template<typename Value1,
    typename Value2>
    bool operator<=(pair<Value1, Value2>% left,
        pair<Value1, Value2>% right);

매개 변수

left
비교할 왼쪽 pair 입니다.

right
비교할 권리 pair 입니다.

설명

연산자 함수는 .를 반환합니다 !(right < left). 두 개체가 요소별로 비교된 후 rightpair 정렬되지 않는지 여부를 left 테스트하는 데 사용합니다.

예시

// cliext_pair_operator_le.cpp
// compile with: /clr
#include <cliext/utility>

int main()
    {
    cliext::pair<wchar_t, int> c1(L'x', 3);
    System::Console::WriteLine("[{0}, {1}]", c1.first, c1.second);
    cliext::pair<wchar_t, int> c2(L'x', 4);
    System::Console::WriteLine("[{0}, {1}]", c2.first, c2.second);

    System::Console::WriteLine("[x 3] <= [x 3] is {0}",
        c1 <= c1);
    System::Console::WriteLine("[x 4] <= [x 3] is {0}",
        c2 <= c1);
    return (0);
    }
[x, 3]
[x, 4]
[x 3] <= [x 3] is True
[x 4] <= [x 3] is False

operator==

pair 같음 비교입니다.

구문

template<typename Value1,
    typename Value2>
    bool operator==(pair<Value1, Value2>% left,
        pair<Value1, Value2>% right);

매개 변수

left
비교할 왼쪽 pair 입니다.

right
비교할 권리 pair 입니다.

설명

연산자 함수는 .를 반환합니다 left.first == right.first && left.second == right.second. 두 개체가 요소별로 비교될 때 pairright 같은 순서가 지정되는지 여부를 left 테스트하는 데 사용합니다.

예시

// cliext_pair_operator_eq.cpp
// compile with: /clr
#include <cliext/utility>

int main()
    {
    cliext::pair<wchar_t, int> c1(L'x', 3);
    System::Console::WriteLine("[{0}, {1}]", c1.first, c1.second);
    cliext::pair<wchar_t, int> c2(L'x', 4);
    System::Console::WriteLine("[{0}, {1}]", c2.first, c2.second);

    System::Console::WriteLine("[x 3] == [x 3] is {0}",
        c1 == c1);
    System::Console::WriteLine("[x 3] == [x 4] is {0}",
        c1 == c2);
    return (0);
    }
[x, 3]
[x, 4]
[x 3] == [x 3] is True
[x 3] == [x 4] is False

pair::operator>

pair 비교보다 큼.

구문

template<typename Value1,
    typename Value2>
    bool operator>(pair<Value1, Value2>% left,
        pair<Value1, Value2>% right);

매개 변수

left
비교할 왼쪽 pair 입니다.

right
비교할 권리 pair 입니다.

설명

연산자 함수는 .를 반환합니다 right < left. 두 개체가 요소별로 비교된 후 rightpair 순서가 지정되는지 여부를 left 테스트하는 데 사용합니다.

예시

// cliext_pair_operator_gt.cpp
// compile with: /clr
#include <cliext/utility>

int main()
    {
    cliext::pair<wchar_t, int> c1(L'x', 3);
    System::Console::WriteLine("[{0}, {1}]", c1.first, c1.second);
    cliext::pair<wchar_t, int> c2(L'x', 4);
    System::Console::WriteLine("[{0}, {1}]", c2.first, c2.second);

    System::Console::WriteLine("[x 3] > [x 3] is {0}",
        c1 > c1);
    System::Console::WriteLine("[x 4] > [x 3] is {0}",
        c2 > c1);
    return (0);
    }
[x, 3]
[x, 4]
[x 3] > [x 3] is False
[x 4] > [x 3] is True

operator>=

pair 보다 크거나 같은 비교입니다.

구문

template<typename Value1,
    typename Value2>
    bool operator>=(pair<Value1, Value2>% left,
        pair<Value1, Value2>% right);

매개 변수

left
비교할 왼쪽 pair 입니다.

right
비교할 권리 pair 입니다.

설명

연산자 함수는 .를 반환합니다 !(left < right). 두 pair 개체가 요소별로 비교될 때 이전에 right 순서가 지정되지 않았는지 여부를 left 테스트하는 데 사용합니다.

예제

// cliext_pair_operator_ge.cpp
// compile with: /clr
#include <cliext/utility>

int main()
    {
    cliext::pair<wchar_t, int> c1(L'x', 3);
    System::Console::WriteLine("[{0}, {1}]", c1.first, c1.second);
    cliext::pair<wchar_t, int> c2(L'x', 4);
    System::Console::WriteLine("[{0}, {1}]", c2.first, c2.second);

    System::Console::WriteLine("[x 3] >= [x 3] is {0}",
        c1 >= c1);
    System::Console::WriteLine("[x 3] >= [x 4] is {0}",
        c1 >= c2);
    return (0);
    }
[x, 3]
[x, 4]
[x 3] >= [x 3] is True
[x 3] >= [x 4] is False