名前空間
変種
操作

std::array

提供: cppreference.com
< cpp‎ | container


 
 
 
std::array
メンバ関数
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.
要素アクセスの循環参照を解除するために使用されている
Original:
Element access
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
array::at
array::operator[]
array::front
array::back
array::data
イテレータ
Original:
Iterators
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
array::begin
array::cbegin
array::end
array::cend
array::rbegin
array::crbegin
array::rend
array::crend
容量
Original:
Capacity
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
array::empty
array::size
array::max_size
修飾子
Original:
Modifiers
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
array::fill
array::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.
get
swap
ヘルパークラス
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
tuple_element
 
Defined in header <array>
template<

    class T,
    std::size_t N

> struct array;
(C++11およびそれ以降)

std::array は固定サイズの配列をカプセル化するコンテナです.

この構造体は Cスタイルの配列と同様のセマンティクスを持ちます. array<T,N> のサイズと効率は、Cスタイルの配列T[N]のサイズと効率と等価です.この構造体は、自身のサイズの把握、代入サポート、ランダムアクセス・イテレータなどといった標準コンテナの利点を提供します。

ゼロの長さの配列のための特殊ケースがあります (N == 0).このケースでは、 array.begin() == array.end() となり, その値はユニークな値になります. サイズ0のarrayに対するfront()back() の呼び出しは未定義です。

array is an aggregate (it has no constructors and no private or protected members), which allows it to use aggregate-initialization.

An array can also be used as a tuple of N elements of the same type.

目次

[編集] メンバータイプ

メンバー·タイプ
Original:
Member type
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Definition
value_type T [edit]
size_type size_t [edit]
difference_type ptrdiff_t [edit]
reference value_type& [edit]
const_reference const value_type& [edit]
pointer T*[edit]
const_pointer const T*[edit]
iterator RandomAccessIterator [edit]
const_iterator
一定のランダムアクセス反復子を返します
Original:
Constant random access iterator
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
[edit]
reverse_iterator std::reverse_iterator<iterator> [edit]
const_reverse_iterator std::reverse_iterator<const_iterator> [edit]

[編集] メンバ関数

要素アクセスの循環参照を解除するために使用されている
Original:
Element access
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
指定された要素にアクセスします。境界チェックを行います。
(パブリックメンバ関数) [edit]
指定された要素にアクセスします
Original:
access specified element
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(パブリックメンバ関数) [edit]
最初の要素にアクセスします
Original:
access the first element
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(パブリックメンバ関数) [edit]
末尾の要素にアクセスします
(パブリックメンバ関数) [edit]
(C++11)
基になる配列へのアクセスを指示する
Original:
direct access to the underlying array
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(パブリックメンバ関数) [edit]
イテレータ
Original:
Iterators
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
先頭を指すイテレータを返します
(パブリックメンバ関数) [edit]
末尾を指すイテレータを返す
Original:
returns an iterator to the end
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(パブリックメンバ関数) [edit]
逆イテレータの先頭を返します
(パブリックメンバ関数) [edit]
逆イテレータの末尾を返します
(パブリックメンバ関数) [edit]
容量
Original:
Capacity
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
コンテナが空であるかどうかをチェックします
(パブリックメンバ関数) [edit]
要素数を返します
Original:
returns the number of elements
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(パブリックメンバ関数) [edit]
要素の最大数を返します
Original:
returns the maximum possible number of elements
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(パブリックメンバ関数) [edit]
操作
Original:
Operations
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
指定された値で容器を満たす
Original:
fill the container with specified value
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(パブリックメンバ関数) [edit]
コンテナの内容をスワップします
(パブリックメンバ関数) [edit]

[編集] 非メンバ関数

辞書的にarray内の値を比較します
Original:
lexicographically compares the values in the array
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(関数テンプレート) [edit]
accesses an element of an array
(関数テンプレート) [edit]
特殊化されたstd::swapアルゴリズム
(関数テンプレート) [edit]

[編集] ヘルパークラス

arrayのサイズを取得します
Original:
obtains the size of an array
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(クラステンプレートの特殊化の2つの値を比較します) [edit]
arrayの要素の型を取得します
Original:
obtains the type of the elements of array
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(クラステンプレートの特殊化の2つの値を比較します) [edit]

[編集]

#include <string>
#include <iterator>
#include <iostream>
#include <algorithm>
#include <array>
 
int main()
{
    // construction uses aggregate initialization
    std::array<int, 3> a1{ {1,2,3} };    // double-braces required
    std::array<int, 3> a2 = {1, 2, 3}; // except after =
    std::array<std::string, 2> a3 = { {std::string("a"), "b"} };
 
    // container operations are supported
    std::sort(a1.begin(), a1.end());
    std::reverse_copy(a2.begin(), a2.end(), std::ostream_iterator<int>(std::cout, " "));
 
    // ranged for loop is supported
    for(auto& s: a3)
        std::cout << s << ' ';
}

Output:

3 2 1 a b