你如何在变量中分配boost :: indices?

时间:2016-02-22 14:41:04

标签: c++ boost boost-multi-array

我正在尝试在变量中存储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)];

有关如何存储此索引对象的任何想法吗?

0 个答案:

没有答案