GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • cpprefjp - C++日本語リファレンス
  • GitHub Project

This view

  • Original page
  • New address

GeezerVison is showing cpprefjp.github.io — std::array::fill - cpprefjp C++日本語リファレンス

  1. リファレンス
  2. array
  3. array
  4. fill

最終更新日時: 2026年09月19日 21時31分51秒 (JST)
rotarymars が更新

履歴 編集

function
<array>

std::array::fill(C++11)

void fill(const T& u);           // C++11
constexpr void fill(const T& u); // C++20

概要

コンテナを指定された値で埋める

効果

fill_n(begin(), N, u)

戻り値

なし

例

#include <iostream>
#include <array>
#include <algorithm>

int main()
{
  std::array<int, 3> ar;

  ar.fill(3);

  std::for_each(ar.begin(), ar.end(), [](int x) {
    std::cout << x << std::endl;
  });
}

出力

3
3
3

バージョン

言語

  • C++11

処理系

  • Clang: 9.0.1 ✅
  • GCC: 4.7.0 ✅
  • Visual C++: 2010 ✅, 2012 ✅

参照

  • LWG Issue 776. Undescribed assign function of std::array
    • assign()という名前だったメンバ関数がfill()に改名された経緯のレポート
  • P1032R1 Misc constexpr bits
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.