bonjour,

cette ligne se compile bien:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
std::map<std::string,std::vector<int[6]>>vect_de_tab;
comment exploite-t-on ce dico?

j'ai essayé:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
#include <vector>
#include <string>
#include <map>
 
int main(){
  std::map<std::string,std::vector<int[6]>>vect_de_tab;
  int T[6]={1,2,3,4,5,6};
  vect_de_tab["Mo"].push_back(T);
  return 0;
}
ça donne:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
In file included from /usr/include/x86_64-linux-gnu/c++/12/bits/c++allocator.h:33,
                 from /usr/include/c++/12/bits/allocator.h:46,
                 from /usr/include/c++/12/vector:61,
                 from main.cpp:1:
/usr/include/c++/12/bits/new_allocator.h: In instantiation of ‘void std::__new_allocator<_Tp>::construct(_Up*, _Args&& ...) [with _Up = int [6]; _Args = {const int (&)[6]}; _Tp = int [6]]’:
/usr/include/c++/12/bits/alloc_traits.h:516:17:   required from ‘static void std::allocator_traits<std::allocator<_Tp1> >::construct(allocator_type&, _Up*, _Args&& ...) [with _Up = int [6]; _Args = {const int (&)[6]}; _Tp = int [6]; allocator_type = std::allocator<int [6]>]’
/usr/include/c++/12/bits/stl_vector.h:1281:30:   required from ‘void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = int [6]; _Alloc = std::allocator<int [6]>; value_type = int [6]]’
main.cpp:8:30:   required from here
/usr/include/c++/12/bits/new_allocator.h:175:11: error: parenthesized initializer in array new
  175 |         { ::new((void *)__p) _Up(std::forward<_Args>(__args)...); }
      |           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/12/bits/new_allocator.h: In instantiation of ‘void std::__new_allocator<_Tp>::destroy(_Up*) [with _Up = int [6]; _Tp = int [6]]’:
/usr/include/c++/12/bits/alloc_traits.h:535:15:   required from ‘static void std::allocator_traits<std::allocator<_Tp1> >::destroy(allocator_type&, _Up*) [with _Up = int [6]; _Tp = int [6]; allocator_type = std::allocator<int [6]>]’
/usr/include/c++/12/bits/vector.tcc:501:28:   required from ‘void std::vector<_Tp, _Alloc>::_M_realloc_insert(iterator, _Args&& ...) [with _Args = {const int (&)[6]}; _Tp = int [6]; _Alloc = std::allocator<int [6]>; iterator = std::vector<int [6]>::iterator]’
/usr/include/c++/12/bits/stl_vector.h:1287:21:   required from ‘void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = int [6]; _Alloc = std::allocator<int [6]>; value_type = int [6]]’
main.cpp:8:30:   required from here
/usr/include/c++/12/bits/new_allocator.h:181:17: error: request for member ‘~int [6]’ in ‘* __p’, which is of non-class type ‘int [6]181 |         { __p->~_Up(); }
      |           ~~~~~~^~~
In file included from /usr/include/c++/12/vector:63:
/usr/include/c++/12/bits/stl_uninitialized.h: In instantiation of ‘constexpr bool std::__check_constructible() [with _ValueType = int [6]; _Tp = int (&&)[6]]’:
/usr/include/c++/12/bits/stl_uninitialized.h:182:4:   required from ‘_ForwardIterator std::uninitialized_copy(_InputIterator, _InputIterator, _ForwardIterator) [with _InputIterator = move_iterator<int (*)[6]>; _ForwardIterator = int (*)[6]]’
/usr/include/c++/12/bits/stl_uninitialized.h:372:37:   required from ‘_ForwardIterator std::__uninitialized_copy_a(_InputIterator, _InputIterator, _ForwardIterator, allocator<_Tp>&) [with _InputIterator = move_iterator<int (*)[6]>; _ForwardIterator = int (*)[6]; _Tp = int [6]]’
/usr/include/c++/12/bits/stl_uninitialized.h:397:2:   required from ‘_ForwardIterator std::__uninitialized_move_if_noexcept_a(_InputIterator, _InputIterator, _ForwardIterator, _Allocator&) [with _InputIterator = int (*)[6]; _ForwardIterator = int (*)[6]; _Allocator = allocator<int [6]>]’
/usr/include/c++/12/bits/vector.tcc:487:3:   required from ‘void std::vector<_Tp, _Alloc>::_M_realloc_insert(iterator, _Args&& ...) [with _Args = {const int (&)[6]}; _Tp = int [6]; _Alloc = std::allocator<int [6]>; iterator = std::vector<int [6]>::iterator]’
/usr/include/c++/12/bits/stl_vector.h:1287:21:   required from ‘void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = int [6]; _Alloc = std::allocator<int [6]>; value_type = int [6]]’
main.cpp:8:30:   required from here
/usr/include/c++/12/bits/stl_uninitialized.h:90:56: error: static assertion failed: result type must be constructible from input type
   90 |       static_assert(is_constructible<_ValueType, _Tp>::value,
      |                                                        ^~~~~
/usr/include/c++/12/bits/stl_uninitialized.h:90:56: note: ‘std::integral_constant<bool, false>::value’ evaluates to false
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
#include <vector>
#include <string>
#include <map>
 
int main(){
  std::map<std::string,std::vector<int[6]>>vect_de_tab;
  vect_de_tab["Mo"][0]=1;
  return 0;
}
ça donne:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
main.cpp: In function ‘int main()’:
main.cpp:8:23: error: incompatible types in assignment of ‘int’ to ‘__gnu_cxx::__alloc_traits<std::allocator<int [6]>, int [6]>::value_type’ {aka ‘int [6]}
    8 |   vect_de_tab["Mo"][0]=1;
quelqu'un a une idée?