X Tutup
The Wayback Machine - https://web.archive.org/web/20240808232540/https://en.cppreference.com/w/cpp/header/inplace_vector
Namespaces
Variants
Views
Actions

Standard library header <inplace_vector> (C++26)

From cppreference.com
< cpp‎ | header
 
 
Standard library headers
Language support
Concepts
<concepts> (C++20)
Diagnostics
<system_error> (C++11)

Memory management
<memory_resource> (C++17)  
Metaprogramming
<type_traits> (C++11)
<ratio> (C++11)
General utilities
<utility>
<tuple> (C++11)
<optional> (C++17)
<variant> (C++17)
<any> (C++17)
<debugging> (C++26)
<expected> (C++23)
<bitset>
<charconv> (C++17)
<format> (C++20)
<bit> (C++20)

Strings
<cuchar> (C++11)

Containers
<flat_set> (C++23)
<span> (C++20)
<mdspan> (C++23)
<inplace_vector> (C++26)
Iterators
<iterator>
Ranges
<ranges> (C++20)
<generator> (C++23)
Algorithms
Numerics
<cfenv> (C++11)
<complex>
<cmath>
<linalg> (C++26)
<numbers> (C++20)

Time
<chrono> (C++11)
Localization
<codecvt> (C++11/17/26*)
<text_encoding> (C++26)
Input/output
<filesystem> (C++17)
<cstdio>
<cinttypes> (C++11)
<strstream> (C++98/26*)
Regular expressions
<regex> (C++11)
Concurrency support
<stop_token> (C++20)
<thread> (C++11)
<atomic> (C++11)
<rcu> (C++26)
<stdatomic.h> (C++23)
<mutex> (C++11)
<shared_mutex> (C++14)

<condition_variable> (C++11)  
<semaphore> (C++20)
<latch> (C++20)

<barrier> (C++20)
<future> (C++11)
<hazard_pointer> (C++26)

C compatibility
<cstdbool> (C++11/17/20*)  
<ccomplex> (C++11/17/20*)
<ctgmath> (C++11/17/20*)

<cstdalign> (C++11/17/20*)

<ciso646> (until C++20)

 

This header is part of the containers library.

Contents

Includes

(C++20)
Three-way comparison operator support[edit]
std::initializer_list class template[edit]

Classes

dynamically-resizable, fixed capacity, inplace contiguous array
(class template) [edit]

Functions

erases all elements satisfying specific criteria
(function template) [edit]

[edit] Synopsis

#include <compare>
#include <initializer_list>
 
namespace std {
  // class template inplace_vector
  template<class T, std::size_t N>
    class inplace_vector; // partially freestanding
 
  // erasure for inplace_vector
  template<class T, std::size_t N, class U>
  constexpr typename inplace_vector<T, N>::size_type
    erase(inplace_vector<T, N>& c, const U& value);
 
  template<class T, std::size_t N, class Predicate>
  constexpr typename inplace_vector<T, N>::size_type
    erase_if(inplace_vector<T, N>& c, Predicate pred);
}

[edit] Class template std::inplace_vector

namespace std {
  template<class T, std::size_t N>
  class inplace_vector {
  public:
    // types:
    using value_type             = T;
    using pointer                = T*;
    using const_pointer          = const T*;
    using reference              = value_type&;
    using const_reference        = const value_type&;
    using size_type              = std::size_t;                 
    using difference_type        = std::ptrdiff_t;             
    using iterator               = /* implementation-defined */;
    using const_iterator         = /* implementation-defined */;
    using reverse_iterator       = std::reverse_iterator<iterator>;
    using const_reverse_iterator = std::reverse_iterator<const_iterator>;
 
    // construct/copy/destroy
    constexpr inplace_vector() noexcept;
    // freestanding-deleted
    constexpr explicit inplace_vector(size_type n);
    // freestanding-deleted
    constexpr inplace_vector(size_type n, const T& value); 
    // freestanding-deleted
    template <class InputIterator>
      constexpr inplace_vector(InputIterator first, InputIterator last); 
    // freestanding-deleted
    template <container-compatible-range<T> R>
      constexpr inplace_vector(std::from_range_t, R&& rg); 
    constexpr inplace_vector(const inplace_vector&);
    constexpr inplace_vector(inplace_vector&&)
      noexcept(N == 0 || std::is_nothrow_move_constructible_v<T>);
    // freestanding-deleted
    constexpr inplace_vector(std::initializer_list<T> il);
    constexpr ~inplace_vector();
    constexpr inplace_vector& operator=(const inplace_vector& other);
    constexpr inplace_vector& operator=(inplace_vector&& other)
      noexcept(N == 0 || 
              (std::is_nothrow_move_assignable_v<T> && 
               std::is_nothrow_move_constructible_v<T>));
    // freestanding-deleted
    constexpr inplace_vector& operator=(std::initializer_list<T>);
 
    // freestanding-deleted
    template <class InputIterator>
      constexpr void assign(InputIterator first, InputIterator last); 
 
    template<container-compatible-range<T> R>
      constexpr void assign_range(R&& rg); // freestanding-deleted
    constexpr void assign(size_type n, const T& u); // freestanding-deleted
    constexpr void assign(std::initializer_list<T> il); // freestanding-deleted
 
    // iterators
    constexpr iterator               begin()         noexcept;
    constexpr const_iterator         begin()   const noexcept;
    constexpr iterator               end()           noexcept;
    constexpr const_iterator         end()     const noexcept;
    constexpr reverse_iterator       rbegin()        noexcept;
    constexpr const_reverse_iterator rbegin()  const noexcept;
    constexpr reverse_iterator       rend()          noexcept;
    constexpr const_reverse_iterator rend()    const noexcept;
 
    constexpr const_iterator         cbegin()  const noexcept;
    constexpr const_iterator         cend()    const noexcept;
    constexpr const_reverse_iterator crbegin() const noexcept;
    constexpr const_reverse_iterator crend()   const noexcept;
 
    // size/capacity
    constexpr bool empty() const noexcept;
    constexpr size_type size() const noexcept;
    static constexpr size_type max_size() noexcept;
    static constexpr size_type capacity() noexcept;
    constexpr void resize(size_type sz); // freestanding-deleted
    constexpr void resize(size_type sz, const T& c); // freestanding-deleted
    static constexpr void reserve(size_type n); // freestanding-deleted
    static constexpr void shrink_to_fit() noexcept;
 
    // element access
    constexpr reference       operator[](size_type n);
    constexpr const_reference operator[](size_type n) const;
    constexpr const_reference at(size_type n) const; // freestanding-deleted
    constexpr reference       at(size_type n); // freestanding-deleted
    constexpr reference       front();
    constexpr const_reference front() const;
    constexpr reference       back();
    constexpr const_reference back() const;
 
    // data access
    constexpr       T* data()       noexcept;
    constexpr const T* data() const noexcept;
 
    // modifiers
    template <class... Args> constexpr reference emplace_back(Args&&... args); 
      // freestanding-deleted
    constexpr reference push_back(const T& x); // freestanding-deleted
    constexpr reference push_back(T&& x); // freestanding-deleted
    template<container-compatible-range<T> R>
      constexpr void append_range(R&& rg); // freestanding-deleted
    constexpr void pop_back();
 
    template<class... Args>
      constexpr pointer try_emplace_back(Args&&... args);
    constexpr pointer try_push_back(const T& x);
    constexpr pointer try_push_back(T&& x);
    template<container-compatible-range<T> R>
      constexpr ranges::borrowed_iterator_t<R> try_append_range(R&& rg);
 
    template<class... Args>
      constexpr reference unchecked_emplace_back(Args&&... args);
    constexpr reference unchecked_push_back(const T& x);
    constexpr reference unchecked_push_back(T&& x);
 
    // freestanding-deleted
    template <class... Args>
      constexpr iterator emplace(const_iterator position, Args&&... args); 
    // freestanding-deleted
    constexpr iterator insert(const_iterator position, const T& x); 
    // freestanding-deleted
    constexpr iterator insert(const_iterator position, T&& x); 
    // freestanding-deleted
    constexpr iterator insert(const_iterator position, size_type n, const T& x); 
    // freestanding-deleted
    template <class InputIterator>
      constexpr iterator insert(const_iterator position, 
                                InputIterator first, InputIterator last);
    // freestanding-deleted
    template<container-compatible-range<T> R>
      constexpr iterator insert_range(const_iterator position, R&& rg); 
    // freestanding-deleted
    constexpr iterator insert(const_iterator position, std::initializer_list<T> il); 
    constexpr iterator erase(const_iterator position);
    constexpr iterator erase(const_iterator first, const_iterator last);
    constexpr void swap(inplace_vector& x)
      noexcept(N == 0 || 
              (std::is_nothrow_swappable_v<T> && 
               std::is_nothrow_move_constructible_v<T>));
    constexpr void clear() noexcept;
 
    constexpr friend bool operator==(const inplace_vector& x, const inplace_vector& y);
    constexpr friend synth-three-way-result<T>
      operator<=>(const inplace_vector& x, const inplace_vector& y);
    constexpr friend void swap(inplace_vector& x, inplace_vector& y)
      noexcept(N == 0 || 
              (std::is_nothrow_swappable_v<T> && 
               std::is_nothrow_move_constructible_v<T>))
      { x.swap(y); }
  };
}
X Tutup