什么是向量中的allocator <t>以及如何使用它?

时间:2018-02-12 05:33:27

标签: c++

这是我第一次在向量中使用allocator函数,我遇到了下面的代码。我想了解它到底要做什么。

EDIT 我已经做了更改建议,当我运行下面的代码我得到一个错误如下..为什么我得到这个?

$destinations = $request['destinations'];
        if($request->has('destinations'))
        {
            $trips = Trip::where('status','=',1)->whereHas('destinations', function($q) {
            $q->where('destinationsid', '=', $destinations);
            })->get();
        }else{
             echo "No destination provided";
        }

代码:

../../../../test_idct.cpp:38:62:   instantiated from here
/proj/xbuilds/2017.4_0206_1/installs/lin64/Vivado/2017.4/lnx64/tools/gcc/bin/../lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/bits/stl_vector.h:206:20: error: no members matching ‘std::vector<short int, aligned_allocator<short int> >::_Base {aka std::_Vector_base<short int, aligned_allocator<short int> >}::_M_allocate’ in ‘std::vector<short int, aligned_allocator<short int> >::_Base {aka struct std::_Vector_base<short int, aligned_allocator<short int> >}’
/proj/xbuilds/2017.4_0206_1/installs/lin64/Vivado/2017.4/lnx64/tools/gcc/bin/../lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/bits/stl_vector.h:207:20: error: no members matching ‘std::vector<short int, aligned_allocator<short int> >::_Base {aka std::_Vector_base<short int, aligned_allocator<short int> >}::_M_deallocate’ in ‘std::vector<short int, aligned_allocator<short int> >::_Base {aka struct std::_Vector_base<short int, aligned_allocator<short int> >}’
/proj/xbuilds/2017.4_0206_1/installs/lin64/Vivado/2017.4/lnx64/tools/gcc/bin/../lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/bits/stl_vector.h:209:20: error: no members matching ‘std::vector<short int, aligned_allocator<short int> >::_Base {aka std::_Vector_base<short int, aligned_allocator<short int> >}::_M_get_Tp_allocator’ in ‘std::vector<short int, aligned_allocator<short int> >::_Base {aka struct std::_Vector_base<short int, aligned_allocator<short int> >}’
../../../../test_idct.cpp: In function ‘int main()’:

0 个答案:

没有答案