just::thread Complete C++ Standard Thread Library by Just Software Solutions

Documentation Home >> Headers >> <thread> Header >> std::vector<std::thread> class template specialization
just::thread specific

std::thread objects are movable, but not copyable. Consequently, the normal implementation of std::vector<> does not support the storage of std::thread objects. In order to allow the use of std::vector<std::thread>, a specialization of std::vector<> is provided.

template<typename Allocator>
class vector<std::thread,Allocator>
{
public:

    class const_iterator;
    class iterator;

    typedef Allocator allocator_type;
    typedef size_t size_type;
    typedef ptrdiff_t difference_type;
    typedef std::thread value_type;
    typedef typename Allocator::pointer pointer;
    typedef typename Allocator::reference reference;
    typedef typename Allocator::const_reference
        const_reference;
    typedef typename Allocator::const_pointer
        const_pointer;
    typedef std::reverse_iterator<iterator>
        reverse_iterator;
    typedef std::reverse_iterator<const_iterator>
        const_reverse_iterator;

    explicit vector(
        const allocator_type& =allocator_type());
    explicit vector(size_type size);

    ~vector();

    void reserve(size_type size);
    void resize(size_type size);
    void clear();
    void push_back(value_type new_value);
    iterator insert(
        iterator pos,value_type new_value);
    void pop_back();
    iterator erase(iterator pos);
    iterator erase(iterator first,iterator last);
    void swap(vector& other);
    bool empty() const;
    size_type capacity() const;
    size_type size() const;
    size_type max_size() const;
    allocator_type get_allocator() const;
    reference operator[](size_type n);
    const_reference operator[](size_type n) const;
    reference at(size_type n);
    const_reference at(size_type n) const;
    reference front();
    const_reference front() const;
    reference back();
    const_reference back() const;
    iterator begin();
    iterator end();
    const_iterator begin() const;
    const_iterator end() const;
    reverse_iterator rbegin();
    reverse_iterator rend();
    const_reverse_iterator rbegin() const;
    const_reverse_iterator rend() const;

    vector(vector const&) = delete;
    vector& operator=(vector const&) = delete;
};

The semantics of the member functions are the same as those of the corresponding member functions of any other specialization of std::vector<>, except that insert and push_back move-construct the values into place rather than copying. Those member functions that cannot be supported with move semantics are omitted.

Header

#include <thread>

See Also