◐ Shell
clean mode source ↗

std::uninitialized_fill_n - cppreference.com

De cppreference.com

<metanoindex/>

<tbody> </tbody>

Definido no cabeçalho

<memory>

template< class ForwardIt, class Size, class T > void uninitialized_fill_n( ForwardIt first, Size count, const T& value )

Copies the given value value to the first count elements in an uninitialized memory area beginning at first. The elements in the uninitialized area are constructed using copy constructor.

Parâmetros

first - the beginning of the range of the elements to initialize
count - number of elements to construct
value -

o valor para a construção dos elementos de

Original:

the value to construct the elements with

The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

Type requirements
-ForwardIt must meet the requirements of ForwardIterator.

Valor de retorno

Iterador para o elemento passado o último elemento copiado.

Original:

Iterator to the element past the last element copied.

The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

Complexidade

Linear em count

Original:

Linear in count

The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

Possível implementação

template< class ForwardIt, class Size, class T >
void uninitialized_fill_n(ForwardIt first, Size count
                          const T& value)
{
    typedef typename std::iterator_traits<ForwardIt>::value_type Value;
    for (; count > 0; ++first, --count) {
        ::new (static_cast<void*>(&*first)) Value(value);
    }
    return first;
}

Exemplo

Veja também

copia um objeto para uma área de memória não inicializada

Original:

copies an object to an uninitialized area of memory

The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.


(modelo de função) [edit]