std::queue<T,Container>::push_range
From cppreference.com
 
 
 
 
 
 C++ 
 Feature test macros (C++20)
 Concepts library (C++20)
 Metaprogramming library (C++11)
 Ranges library (C++20)
 Filesystem library (C++17)
 Concurrency support library (C++11)
 Execution control library (C++26)
Containers library 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
(C++17)
(C++11)
(C++26)
(C++26)
(C++11)
(C++11)
(C++11)
(C++11)
(C++11)
(C++23)
(C++23)
(C++23)
(C++23)
(C++20)
(C++23)
 Tables
std::queue template< container-compatible-range <value_type> R >
void push_range( R&& rg );
 
 (since C++23) 
void push_range( R&& rg );
Inserts a copy of each element of rg in queue, as if by:
-  c.append_range(std::forward <R>(rg)) if that is a valid expression (i.e. the underlying container c has an appropriate append_rangemember function), or
- ranges::copy (rg, std::back_inserter (c)) otherwise.
Each iterator in the range rg is dereferenced exactly once.
Contents
[edit] Parameters
[edit] Complexity
Identical to the complexity of c.append_range or ranges::copy (rg, std::back_inserter (c)) (depending on what function is used internally).
[edit] Notes
| Feature-test macro | Value | Std | Feature | 
|---|---|---|---|
| __cpp_lib_containers_ranges | 202202L | (C++23) | Ranges-aware construction and insertion | 
[edit] Example
Run this code
#include <initializer_list> #include <queue> #include <version> #ifdef __cpp_lib_format_ranges #include <print> using std::println ; #else #define FMT_HEADER_ONLY #include <fmt/ranges.h> using fmt::println; #endif int main() { std::queue <int> adaptor; const auto rg = {1, 3, 2, 4}; #ifdef __cpp_lib_containers_ranges adaptor.push_range(rg); #else for (int e : rg) adaptor.push(e); #endif println("{}", adaptor); }
Output:
[1, 3, 2, 4]