[#bsl-vector-00d-2constructor-037] = xref:bsl.adoc[bsl]::xref:bsl/vector-00d.adoc[vector]::vector :relfileprefix: ../../ :mrdocs: Constructors == Synopses Declared in `<bslstl_vector.h>` Create an empty vector. [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- xref:bsl/vector-00d/2constructor-0c87.adoc[vector]() noexcept; ---- [.small]#xref:bsl/vector-00d/2constructor-0c87.adoc[_» more..._]# Create a vector having the same value as the specified `original` object. Use the allocator returned by 'bsl::allocator_traits<ALLOCATOR>:: select_on_container_copy_construction(original.get_allocator())' to allocate memory. This method requires that the (template parameter) type `VALUE_TYPE` be `copy‐insertable` into this vector (see {Requirements on `VALUE_TYPE`}). [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- xref:bsl/vector-00d/2constructor-01b.adoc[vector](xref:bsl/vector-00d.adoc[vector] const& original); ---- [.small]#xref:bsl/vector-00d/2constructor-01b.adoc[_» more..._]# Create a vector having the same value as the specified `original` object by moving (in constant time) the contents of `original` to the new vector. The allocator associated with `original` is propagated for use in the newly‐created vector. `original` is left in a valid but unspecified state. [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- xref:bsl/vector-00d/2constructor-05d.adoc[vector](xref:BloombergLP/bslmf/MovableRef.adoc[BloombergLP::bslmf::MovableRef<vector>] original) noexcept; ---- [.small]#xref:bsl/vector-00d/2constructor-05d.adoc[_» more..._]# Create an empty vector. Optionally specify a `basicAllocator` used to supply memory. If `basicAllocator` is not specified, a default‐constructed object of the (template parameter) type `ALLOCATOR` is used. If the type `ALLOCATOR` is `bsl::allocator` and `basicAllocator` is not supplied, the currently installed default allocator is used. Note that a `bslma::Allocator *` can be supplied for `basicAllocator` if the type `ALLOCATOR` is `bsl::allocator` (the default). [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- explicit xref:bsl/vector-00d/2constructor-0c8a.adoc[vector](ALLOCATOR const& basicAllocator) noexcept; ---- [.small]#xref:bsl/vector-00d/2constructor-0c8a.adoc[_» more..._]# Create a vector of the specified `initialSize` whose every element is a default‐constructed object of the (template parameter) type `VALUE_TYPE`. Optionally specify a `basicAllocator` used to supply memory. If `basicAllocator` is not specified, a default‐constructed object of the (template parameter) type `ALLOCATOR` is used. If the type `ALLOCATOR` is `bsl::allocator` and `basicAllocator` is not supplied, the currently installed default allocator is used. Throw `std::length_error` if `initialSize > max_size()`. This method requires that the type `VALUE_TYPE` be `default‐insertable` into this vector (see {Requirements on `VALUE_TYPE`}). Note that a `bslma::Allocator *` can be supplied for `basicAllocator` if the type `ALLOCATOR` is `bsl::allocator` (the default). [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- explicit xref:bsl/vector-00d/2constructor-07.adoc[vector]( xref:bsl/vector-00d/size_type.adoc[size_type] initialSize, ALLOCATOR const& basicAllocator = ALLOCATOR()); ---- [.small]#xref:bsl/vector-00d/2constructor-07.adoc[_» more..._]# Create a vector having the same value as the specified `original` object that uses the specified `basicAllocator` to supply memory. The contents of `original` are moved (in constant time) to the new vector if `basicAllocator == original.get_allocator()`, and are move‐inserted (in linear time) using `basicAllocator` otherwise. `original` is left in a valid but unspecified state. This method requires that the (template parameter) type `VALUE_TYPE` be `move‐insertable` into this vector (see {Requirements on `VALUE_TYPE`}). Note that a `bslma::Allocator *` can be supplied for `basicAllocator` if the (template parameter) type `ALLOCATOR` is `bsl::allocator` (the default). [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- xref:bsl/vector-00d/2constructor-0e5.adoc[vector]( xref:BloombergLP/bslmf/MovableRef.adoc[BloombergLP::bslmf::MovableRef<vector>] original, ALLOCATOR const& basicAllocator); ---- [.small]#xref:bsl/vector-00d/2constructor-0e5.adoc[_» more..._]# Create a vector and insert (in order) each `VALUE_TYPE` object in the specified `values` initializer list. Optionally specify a `basicAllocator` used to supply memory. If `basicAllocator` is not specified, a default‐constructed object of the (template parameter) type `ALLOCATOR` is used. If the type `ALLOCATOR` is `bsl::allocator` and `basicAllocator` is not supplied, the currently installed default allocator is used. This method requires that the (template parameter) type `VALUE_TYPE` be `copy‐insertable` into this vector (see {Requirements on `VALUE_TYPE`}). Note that a `bslma::Allocator *` can be supplied for `basicAllocator` if the type `ALLOCATOR` is `bsl::allocator` (the default). [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- xref:bsl/vector-00d/2constructor-031.adoc[vector]( std::initializer_list<VALUE_TYPE> values, ALLOCATOR const& basicAllocator = ALLOCATOR()); ---- [.small]#xref:bsl/vector-00d/2constructor-031.adoc[_» more..._]# Create a vector having the same value as the specified `original` object that uses the specified `basicAllocator` to supply memory. This method requires that the (template parameter) type `VALUE_TYPE` be `copy‐insertable` into this vector (see {Requirements on `VALUE_TYPE`}). Note that a `bslma::Allocator *` can be supplied for `basicAllocator` if the (template parameter) type `ALLOCATOR` is `bsl::allocator` (the default). [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- xref:bsl/vector-00d/2constructor-01a.adoc[vector]( xref:bsl/vector-00d.adoc[vector] const& original, ALLOCATOR const& basicAllocator); ---- [.small]#xref:bsl/vector-00d/2constructor-01a.adoc[_» more..._]# Create a vector of the specified `initialSize` whose every element is a copy of the specified `value`. Optionally specify a `basicAllocator` used to supply memory. If `basicAllocator` is not specified, a default‐constructed object of the (template parameter) type `ALLOCATOR` is used. If the type `ALLOCATOR` is `bsl::allocator` and `basicAllocator` is not supplied, the currently installed default allocator is used. Throw `std::length_error` if `initialSize > max_size()`. This method requires that the (template parameter) type `VALUE_TYPE` be `copy‐insertable` into this vector (see {Requirements on `VALUE_TYPE`}). Note that a `bslma::Allocator *` can be supplied for `basicAllocator` if the type `ALLOCATOR` is `bsl::allocator` (the default). [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- xref:bsl/vector-00d/2constructor-0e1.adoc[vector]( xref:bsl/vector-00d/size_type.adoc[size_type] initialSize, VALUE_TYPE const& value, ALLOCATOR const& basicAllocator = ALLOCATOR()); ---- [.small]#xref:bsl/vector-00d/2constructor-0e1.adoc[_» more..._]# Create a vector, and insert (in order) each `VALUE_TYPE` object in the range starting at the specified `first` element, and ending immediately before the specified `last` element. Optionally specify a `basicAllocator` used to supply memory. If `basicAllocator` is not specified, a default‐constructed object of the (template parameter) type `ALLOCATOR` is used. If the type `ALLOCATOR` is `bsl::allocator` and `basicAllocator` is not supplied, the currently installed default allocator is used. Throw `std::length_error` if the number of elements in `[first .. last)]` exceeds the value returned by the method `max_size`. The (template parameter) type `INPUT_ITER` shall meet the requirements of an input iterator defined in the C++11 standard [24.2.3]providing access to values of a type convertible to `value_type`, and `value_type` must be `emplace‐constructible` from `*i` into this vector, where `i` is a dereferenceable iterator in the range `[first .. last)]` (see {Requirements on `VALUE_TYPE`}). The behavior is undefined unless `first` and `last` refer to a range of valid values where `first` is at a position at or before `last`. Note that a `bslma::Allocator *` can be supplied for `basicAllocator` if the type `ALLOCATOR` is `bsl::allocator` (the default). [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- template<class INPUT_ITER> xref:bsl/vector-00d/2constructor-051.adoc[vector]( INPUT_ITER first, INPUT_ITER last, ALLOCATOR const& basicAllocator = ALLOCATOR()); ---- [.small]#xref:bsl/vector-00d/2constructor-051.adoc[_» more..._]# Create a vector from the elements of the specifed `range`. Optionally specify a `basicAllocator` used to supply memory. If `basicAllocator` is not specified, a default‐constructed object of the (template parameter) type `ALLOCATOR` is used. Note that `range` must meet the requirements of an input range and the values from `range` must have a type matching or convertible to (template parameter) `VALUE_TYPE`. [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- template<class t_RANGE> xref:bsl/vector-00d/2constructor-0d.adoc[vector]( std::from_range_t, t_RANGE&& range, ALLOCATOR const& basicAllocator = ALLOCATOR()); ---- [.small]#xref:bsl/vector-00d/2constructor-0d.adoc[_» more..._]# [.small]#Created with https://www.mrdocs.com[MrDocs]#