std :: tr1 :: array는 boost :: array와 같았으므로 인덱스에 액세스 할 때 예외가 발생합니다 출입 금지 구역의. 사실, 나는 머리글을 들여다 보았다. 누군가 다음과 같은 코드가 버스 오류 (gcc 버전 4.0.1 (Apple Inc. build 5465)) 및 gcc 4.1.2의 segfault를 초래하는 이유를 설명 할 수 있습니까?std :: tr1 :: array와 boost :: array의 차이점
감사합니다.
#include <exception>
#include <iostream>
#include <string>
#include <tr1/array>
#include <boost/array.hpp>
int main()
{
// boost::array<std::string, 3> arr;
std::tr1::array<std::string, 3> arr;
try
{
arr.at(0) = "one";
arr.at(1) = "two";
arr.at(2) = "three";
arr.at(3) = "nogood";
}
catch (const std::exception& e)
{
std::cout << "exception: " << e.what() << std::endl;
}
return 0;
}
난 그냥 gcc 4.1.2와 그것을 시도하고 예상되는 예외가있어. 이것이 정확한 코드일까요? –