比如说queue<int[4]> q;是否合法?
如下代码会报错
#include<bits/stdc++.h>
using namespace std;
queue<int[4]> q;
int tmp[4];
signed main(){
q.push(tmp);
return 0;
}
补充报错如下
In file included from ... :
.../13.1.0/include/c++/bits/alloc_traits.h: In instantiation of 'static constexpr void std::allocator_traits<std::allocator<_CharT> >::construct(allocator_type&, _Up*, _Args&& ...) [with _Up = int [4]; _Args = {const int (&)[4]}; _Tp = int [4]; allocator_type = std::allocator<int [4]>]':
.../stl_deque.h:1543:30: required from 'void std::deque<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = int [4]; _Alloc = std::allocator<int [4]>; value_type = int [4]]'
.../stl_queue.h:286:20: required from 'void std::queue<_Tp, _Sequence>::pus
(const value_type&) [with _Tp = int [4]; _Sequence = std::deque<int [4], std::allocator<int [4]> >; value_type = int [4]]'
...\2txt.cpp:6:8: required from here
.../alloc_traits.h:539:28: error: no matching function for call to 'construct_at(int (*&)[4], const int [4])'
539 | std::construct_at(__p, std::forward<_Args>(__args)...);
| ~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from... :
C:/Users/dwdyy/Documents/Files/mingw64/lib/gcc/x86_64-w64-mingw32/13.1.0/include/c++/bits/stl_construct.h:94:5: note: candidate: 'template<class _Tp, class ... _Args> constexpr decltype (::new(void*(0)) _Tp) std::construct_at(_Tp*, _Args&& ...)'
94 | construct_at(_Tp* __location, _Args&&... __args)
| ^~~~~~~~~~~~
.../stl_construct.h:94:5: note: template argument deduction/substitution failed:
.../stl_construct.h: In substitution of 'template<class _Tp, class ... _Args> constexpr decltype (::new(void*(0)) _Tp) std::construct_at(_Tp*, _Args&& ...) [with _Tp = int [4]; _Args = {const int (&)[4]}]':
.../alloc_traits.h:539:21: required from 'static constexpr void std::allocator_traits<std::allocator<_CharT> >::construct(allocator_type&, _Up*, _Args&& ...)
[with _Up = int [4]; _Args = {const int (&)[4]}; _Tp = int [4]; allocator_type = std::allocator<int [4]>]'
.../stl_deque.h:1543:30: required from 'void std::deque<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = int [4]; _Alloc = std::allocator<int [4]>; value_type = int [4]]'
.../stl_queue.h:286:20: required from 'void std::queue<_Tp, _Sequence>::pus
(const value_type&) [with _Tp = int [4]; _Sequence = std::deque<int [4], std::allocator<int [4]> >; value_type = int [4]]'
c:\Users\dwdyy\Documents\Files\Prog\OI\unaccepted\2txt.cpp:6:8: required from here
.../13.1.0/include/c++/bits/stl_construct.h:96:56: error: invalid conversion from 'const int*' to 'in
' [-fpermissive]
96 | -> decltype(::new((void*)0) _Tp(std::declval<_Args>()...))
| ~~~~~~~~~~~~~~~~~~~^~
| |