나는 func1()
으로 전달하고자하는 std::array
과 boost::fusion::vector<X, Y>
을 가지고 있습니다. 이 함수는 각 std::array
요소에 boost::fusion::vector<X, Y>
인스턴스를 추가합니다.boost :: fusion :: vector <x,y,z> 요소를 std :: array <boost :: fusion :: vector <x,y,z>>에 추가하는 방법은 무엇입니까?
올바른 숫자의 숫자를 fusion::vector<X,Y>
에 추가 할 수 있도록 fusion::fold()
을 사용해야합니다. 맞습니까?
그래서 나는 현재 이런 일이 :
void func1(){
boost::fusion::vector<X,Y> my_vec;
std::array<boost::fusion::vector<X,Y> > my_array[10];
func2(my_vec, my_array);
}
void func2(boost::fusion::vector<X,Y> my_vec, std::array<boost::fusion::vector<X,Y> > my_array){
//THIS IS THE PART I AM UNSURE ABOUT
for(int k=0; k<10; k++){
//The first two parameters aren't so important- just included to show the idea
my_array[k] = boost::fusion::fold(my_vec, 1, some_struct);
}
}
//This part is irrelevant
struct some_struct
{
typedef int result_type;
template<typename T>
int operator()(int x, T& t) const
{
t = something(x);
//Not sure if this part needs to return a boost::fusion::vector<X, Y>
return x;
}
};
여러 boost::fusion::vector<X,Y>
인스턴스를 생성하기 위해 my_vec
의 서명을 사용하고 내가 추가 할 수 있도록 그들을 다시 반환하는 방법입니다에 대해 내가 확신하고있는 부분 배열에 func2()
.
누군가가 조언을 해주실 수 있습니까?
편집 - 방금 fold()
에 대한 첫 번째 매개 변수가 있음을 발견하고 내 질문을 수정했습니다.
나는 수많은 fusion :: vector을 만들고 싶습니다. 그리고이 각각의 인스턴스는 std :: array에 저장되어야합니다. 이게 도움이 되나요? –
user3125975
@ user3125975 예/아니요. 그것은 기본적으로 당신이 여기'std :: array> my_array [10];'에서하고있는 것이므로, 여러분은 그것들을 특정한 방법으로 초기화하고 싶다고 가정합니다. 왜 단지'my_array [k] = something()'이 아니며,'something'은'somestruct'에서 호출하는 하나의'fusion :: vector'를 반환하는 함수입니까? –
Johan
something()은 벡터에 넣을 요소의 개수를 어떻게 알 수 있습니까? my_vec의 형식을 "확인"해야합니까? – user3125975