名前空間
変種
操作

std::pair::pair

提供: cppreference.com
< cpp‎ | utility‎ | pair

 
 
ユーティリティライブラリ
支援を入力します (basic types, RTTI, type traits)
動的なメモリ管理
エラー処理
プログラムユーティリティ
可変個引数関数
日付と時刻
関数オブジェクト
initializer_list(C++11)
bitset
hash(C++11)
関係演算子
Original:
Relational operators
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
rel_ops::operator!=
rel_ops::operator>
rel_ops::operator<=
rel_ops::operator>=
ペアとタプル
Original:
Pairs and tuples
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
pair
tuple(C++11)
piecewise_construct_t(C++11)
piecewise_construct(C++11)
フォワード、スワップ、および移動
Original:
Swap, forward and move
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
swap
forward(C++11)
move(C++11)
move_if_noexcept(C++11)
declval(C++11)
 
std::pair
メンバ関数
Original:
Member functions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
pair::pair
pair::operator=
pair::swap
非メンバ関数
Original:
Non-member functions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
make_pair
operator=
operator!=
operator<
operator<=
operator>
operator>=
std::swap
get(C++11)
ヘルパークラス
Original:
Helper classes
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
tuple_size(C++11)
tuple_element(C++11)
 
pair();
constexpr pair();
(1) (C++11以前)
(C++11およびそれ以降)
pair( const T1& x, const T2& y );
(2)
template< class U1, class U2 >
pair( U1&& x, U2&& y );
(3) (C++11およびそれ以降)
template< class U1, class U2 >
pair( const pair<U1,U2>& p );
(4)
template< class U1, class U2 >
pair( pair<U1,U2>&& p );
(5) (C++11およびそれ以降)
template< class... Args1, class... Args2 >

pair( std::piecewise_construct_t,
      std::tuple<Args1...> first_args,

      std::tuple<Args2...> second_args );
(6) (C++11およびそれ以降)
pair( const pair& p ) = default;
(7)
pair( pair&& p ) = default;
(8) (C++11およびそれ以降)


新しいペアを構築し.
Original:
Constructs a new pair.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
1)
デフォルトのコンストラクタです。値初期化ペアの両方の要素を、firstsecond.
Original:
Default constructor. Value-initializes both elements of the pair, first and second.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
2)
firstxを初期化し、secondyと.
Original:
Initializes first with x and second with y.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
3)
firststd::forward<U1>(x)を初期化し、secondstd::forward<U2>(y)と.
Original:
Initializes first with std::forward<U1>(x) and second with std::forward<U2>(y).
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
4)
firstp.firstを初期化し、secondp.secondと.
Original:
Initializes first with p.first and second with p.second.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
5)
firststd::move<U1>(p.first)を初期化し、secondstd::move<U2>(p.second)と.
Original:
Initializes first with std::move<U1>(p.first) and second with std::move<U2>(p.second).
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
6)
転送転送first_argsのコンストラクタにfirstの要素とsecond_argsのコンストラクタにsecondの要素。これは、非コピー可能な非可動型のペアを作成するために使用できる唯一の​​非デフォルトコンストラクタです.
Original:
Forwards the elements of first_args to the constructor of first and forwards the elements of second_args to the constructor of second. This is the only non-default constructor that can be used to create a pair of non-copyable non-movable types.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
7)
コピーコンストラクタが暗黙的に生成され.
Original:
Copy constructor is implicitly generated.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
8)
ムーブコンストラクタが暗黙的に生成され.
Original:
Move constructor is implicitly generated.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

[編集] パラメータ

x -
このペアの最初の要素を初期化する値
Original:
value to initialize the first element of this pair
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
y -
このペアの2番目の要素を初期化するための値
Original:
value to initialize the second element of this pair
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
p -
このペアの両方の要素を初期化するために使用される値のペア
Original:
pair of values used to initialize both elements of this pair
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
first_args -
このペアの最初の要素を初期化するコンストラクタの引数のタプル
Original:
tuple of constructor arguments to initialize the first element of this pair
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
second_args -
このペアの2番目の要素を初期化するコンストラクタの引数のタプル
Original:
tuple of constructor arguments to initialize the second element of this pair
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

[編集]

#include <utility>
#include <string>
#include <complex>
#include <tuple>
#include <iostream>
int main()
{
    std::pair<int, float> p1;
    std::cout << "Value-initialized: "
              << p1.first << ", " << p1.second << '\n';
 
    std::pair<int, double> p2(42, 0.123);
    std::cout << "Initialized with two values: "
              << p2.first << ", " << p2.second << '\n';
 
    std::pair<char, int> p4(p2);
    std::cout << "Implicitly converted: "
              << p4.first << ", " << p4.second << '\n';
 
    std::pair<std::complex<double>, std::string> p6(
                    std::piecewise_construct, 
                    std::forward_as_tuple(0.123, 7.7),
                    std::forward_as_tuple(10, 'a'));
    std::cout << "Piecewise constructed: "
              << p6.first << ", " << p6.second << '\n';
}

Output:

Value-initialized: 0, 0
Initialized with two values: 42, 0.123
Implicitly converted: *, 0
Piecewise constructed: (0.123,7.7), aaaaaaaaaa

[編集] も参照してください

引数の型によって定義されたタイプのpairオブジェクトを作成します
Original:
creates a pair object of type, defined by the argument types
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(関数テンプレート) [edit]