◐ Shell
clean mode source ↗

std::uninitialized_fill – cppreference.com

Aus cppreference.com

<metanoindex/>

<tbody> </tbody>

definiert in Header

<memory>

template< class ForwardIt, class T > void uninitialized_fill( ForwardIt first, ForwardIt last, const T& value )

Initialisiert einen uninitialisierten Speicherbereich, der durch [first, last) begrenzt wird, mit dem übergebenen Wert value. Die Elemente im definierten Bereich werden mit Hilfe des Kopierkonstruktors initialisiert.

Original:

Copies the given value value to an uninitialized memory area, defined by the range [first, last). The elements in the uninitialized area are constructed using copy constructor.

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

Parameter

first, last -

definiert den zu initialisierenden Bereich

Original:

the range of the elements to initialize

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

value -

der Wert, mit dem die Elemente belegt werden

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.

Rückgabewert

(None)

Original:

(none)

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

Komplexität

Linear im Abstand first und last

Original:

Linear in the distance between first and last

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

Mögliche Implementierung

template<class ForwardIt, class T>
void uninitialized_fill(ForwardIt first, 
                        ForwardIt last,
                        const T& value)
{
    typedef typename std::iterator_traits<ForwardIt>::value_type Value;
    for (; first != last; ++first) {
        ::new (static_cast<void*>(&*first)) Value(value);
    }
}

Beispiel

Siehe auch