Skip site navigation (1)Skip section navigation (2)

FreeBSD Manual Pages

  
 
  

home | help
std::array::fill(3)	      C++ Standard Libary	   std::array::fill(3)

NAME
       std::array::fill	- std::array::fill

Synopsis
	  void fill( const T& value );	(since C++11)
					(constexpr since C++20)

	  Assigns the value to all elements in the container.

Parameters
	  value	- the value to assign to the elements

Return value
	  (none)

Complexity
	  Linear in the	size of	the container.

Example
       // Run this code

	#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");
	}

Possible output:

See also
	  fill		copy-assigns  the  given  value	 to every element in a
       range
		       (function template)
	  fill_n       copy-assigns the	given value to N elements in a range
		       (function template)
	  ranges::fill assigns a range of elements a certain value
	  (C++20)      (niebloid)

http://cppreference.com		  2024.06.10		   std::array::fill(3)

Want to link to this manual page? Use this URL:
<https://man.freebsd.org/cgi/man.cgi?query=std::array::fill&sektion=3&manpath=FreeBSD+Ports+15.1.quarterly>

home | help