std::array<T,N>:: fill
From de.cppreference.net
|
void
fill
(
const
T
&
value
)
;
|
(seit C++11)
(constexpr seit C++20) |
|
Weist allen Elementen im Container den value zu.
InhaltParameter
Rückgabewert(keine) KomplexitätLinear in der Größe des Containers. Beispiel
Diesen Code ausführen
#include <array> #include <cstddef> #include <iostream> int main() { constexpr std::size_t xy = 4; using Cell = std::array<unsigned char, 8>; std::array<Cell, xy * xy> board; board.fill({0xE2, 0x96, 0x84, 0xE2, 0x96, 0x80, 0, 0}); // "▄▀"; for (std::size_t count{}; Cell c : board) std::cout << c.data() << ((++count % xy) ? "" : "\n"); } Mögliche Ausgabe: ▄▀▄▀▄▀▄▀ ▄▀▄▀▄▀▄▀ ▄▀▄▀▄▀▄▀ ▄▀▄▀▄▀▄▀ Siehe auch
|