我正在尝试在变量中存储boost::indices
。根据我的收集,这会产生index_gen
类型。但是,index_gen
似乎模仿boost::detail
,但模板参数未向multi_array::index_gen
公开,并且它们似乎默认为<0,0>
,这会产生错误'{1}}见下文:
我尝试了以下内容:
#include "boost/multi_array.hpp"
int main()
{
typedef boost::multi_array<double, 3> array_type;
using IndexType = boost::array<array_type::index, 3>;
array_type A;
A.reshape(IndexType({{3,4,2}}));
// this works
array_type::array_view<3>::type myview =
A[ boost::indices[array_type::index_range(0,2)][array_type::index_range(1,3)][array_type::index_range(0,4)] ];
// This produces a compiler error:
array_type::index_gen test = boost::indices[array_type::index_range(0,2)][array_type::index_range(1,3)][array_type::index_range(0,4)];
}
错误是:
error: conversion from 'boost::detail::multi_array::index_gen<3, 3>' to non-scalar type 'boost::detail::multi_array::multi_array_base::index_gen {aka boost::detail::multi_array::index_gen<0, 0>}' requested
array_type::index_gen test = boost::indices[array_type::index_range(0,2)][array_type::index_range(1,3)][array_type::index_range(0,4)];
有关如何存储此索引对象的任何想法吗?