[ Web Proxy ]
URL:
Viewing: https://ru.cppreference.com/cpp/container/list/list [Back]  [Original]

std::list::list cppreference.com
cppreference.com

std::list::list

cppreference.com
<tbody> </tbody>
explicit list( const Allocator& alloc = Allocator() );
(1)
explicit list( size_type count, {{#pad:|4}} const T& value = T(), {{#pad:|4}} const Allocator& alloc = Allocator()); list( size_type count, {{#pad:|4}} const T& value, {{#pad:|4}} const Allocator& alloc = Allocator());
(2) ( C++11)


( C++11)
explicit list( size_type count );
(3) ( C++11)
template< class InputIt > list( InputIt first, InputIt last, {{#pad:|4}} const Allocator& alloc = Allocator() );
(4)
list( const list& other );
(5)
list( const list& other, const Allocator& alloc );
(5) ( C++11)
list( list&& other )
(6) ( C++11)
list( list&& other, const Allocator& alloc );
(6) ( C++11)
list( std::initializer_list<T> init, {{#pad:|4}} const Allocator& alloc = Allocator() );
(7) ( C++11)

, , alloc.

1) . .
2) count value.
3) count T, -. .
4) [first, last).
5) . other. alloc , std::allocator_traits<allocator_type>::select_on_copy_construction(other).
6) . other . alloc , other.
7) init.

alloc , .
count .
value , .
first, last , .
other , .
init .
-
InputIt InputIterator.

1) .
2-3) count.
4) first last.
5) other
6) . alloc alloc != other.get_allocator(), .
7) init

#include <list>
#include <string>

int main()
{
    // c++11 initializer list syntax:
    std::list<std::string> words1 {"the", "frogurt", "is", "also", "cursed"};

    // words2 == words1
    std::list<std::string> words2(words1.begin(), words1.end());

    // words3 == words1
    std::list<std::string> words3(words1);

    // words4 is {"Mo", "Mo", "Mo", "Mo", "Mo"}
    std::list<std::string> words4(5, "Mo");

    return 0;
}

.


(public -) []

(public -) []

Web Proxy Viewer  |  New URL  |  Original Page