2016-08-11 10 views
2

ブーストマルチアレイイテレータにarrow演算子がありませんか?これがうまくいくと私は間違っていますか?arrow演算子とブーストマルチアレイイテレータ

#include <vector> 
#include <boost/multi_array.hpp> 

struct foo { 
    int n; 
}; 

int main() 
{ 
    { 
     std::vector<foo> a; 
     auto it = a.begin(); 
     int test = it->n; // this does compile 
    } 

    { 
     boost::multi_array<foo, 1> a; 
     auto it = a.begin(); 
     int test = it->n; // this does not compile 
    } 
    return 0; 
} 
+0

どのような種類のコンパイルエラーが発生しますか? –

+0

'' - >':参照へのポインタが不正です.' \ boost \ multi_array \ iterator.hpp – cambunctious

答えて

2

バグのようです。 array_iterator::operator->リターン:

// reference here is foo& 
operator_arrow_proxy<reference> operator->() const; 

:ここ

template <class T> 
struct operator_arrow_proxy 
{ 
    operator_arrow_proxy(T const& px) : value_(px) {} 
    T* operator->() const { return &value_; } 
    // This function is needed for MWCW and BCC, which won't call operator-> 
    // again automatically per 13.3.1.2 para 8 
    operator T*() const { return &value_; } 
    mutable T value_; 
}; 

しかしT*foo&*だろうと、あなたは参照へのポインタを取ることができません。さらに、mutable参照メンバを持つことはできません。だから、この全体のクラステンプレートは、このユースケースのためにちょうど壊れています。

+0

shucks。これは簡単に修正できますか? – cambunctious

+0

@camunctious私はそう思います。 – Barry

関連する問題