(C++17) | ||||
| Sequence | ||||
(C++11) | ||||
(C++26) | ||||
(C++26) | ||||
(C++11) | ||||
| Associative | ||||
| Unordered associative | ||||
(C++11) | ||||
(C++11) | ||||
(C++11) | ||||
(C++11) | ||||
| Adaptors | ||||
(C++23) | ||||
(C++23) | ||||
(C++23) | ||||
(C++23) | ||||
| Views | ||||
(C++20) | ||||
(C++23) | ||||
| Tables | ||||
| Iterator invalidation | ||||
| Member function table | ||||
| Non-member function table |
| Member types | ||||||
| Member functions | ||||||
| Non-member functions | ||||||
| ||||||
| Helper classes | ||||||
| Deduction guides(C++17) | ||||||
void fill(const T& value); | (since C++11) (constexpr since C++20) | |
Assigns thevalue to all elements in the container.
Contents |
| value | - | the value to assign to the elements |
(none)
Linear in the size of the container.
#include <array>#include <cstddef>#include <iostream> int main(){constexprstd::size_t xy=4; using Cell=std::array<unsignedchar,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");}
Possible output:
▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀
| copy-assigns the given value to every element in a range (function template)[edit] | |
| copy-assigns the given value to N elements in a range (function template)[edit] | |
(C++20) | assigns a range of elements a certain value (algorithm function object)[edit] |