std :: array内部的std :: vector

时间:2019-05-22 20:59:21

标签: c++ memory-management dynamic-memory-allocation

很多时候在解决Leetcode问题时,我会做一些测试用例,其输入为std::vector<int>,输出为整数。因此,在main,中,我将写

int main()
{
    constexpr std::size_t n_tests;
    std::array<std::pair<std::vector<int>, int>, n_tests> tests
    {
        //...    
    };
    // ...
}

问题:在内存分配方面,std::array包含std::vector作为其一部分的Integer % 2 bytes –32,768 to 32,767 Long & 4 bytes –2,147,483,648 to 2,147,486,647 Currency @ 8 bytes –922,337,203,477.5808 to 922,337,203,685,477.5807 Single ! 4 bytes –3402823E38 to –1.401298E–45 or 1.401298E–45 to 3.402823E38 Double # 8 bytes –1.79769313486232E308 to –4.94065645841247E–324 or 1.79769313486232E308 to 4.94065645841247E–324 String $ 1 to 65,400 characters Variant string 0 to 2 billion characters. Decimal -79,228,162,514,264,337,593,543,950,335 to 79,228,162,514,264,337,593,543,950,335 or –7.2998162514264337593543950335 to 7.9228162514264337593543950335 中发生了什么?堆栈与堆等

0 个答案:

没有答案