我試圖使用boost::iterator_facade
以及不完整的Value
模板參數。這失敗了,因爲iterator_facade
正在嘗試 檢查類型是否爲is_pod
。具有不完整值參數的Boost.Iterator Facade
這是預期的行爲?我能以某種方式在 中解決這個限制嗎?我可以編寫一個簡單代理foo
和 提供隱式轉換的類模板,但我寧願有一個更簡單的 解決方案。
#include <boost/iterator/iterator_facade.hpp>
class iter
: public boost::iterator_facade< iter,
iter,
boost::forward_traversal_tag
>
{
private:
friend class boost::iterator_core_access;
void increment() { }
bool equal(iter const& other) const { return true; }
iter& dereference() const { return const_cast<iter&>(static_cast<const iter&>(*this)); }
};
int main()
{
iter f;
return 0;
}
只是偶然發現了完全相同的問題。似乎促進開發者試圖變得太聰明,並忽略了上述情況,即使對於標準庫中的許多迭代器也是如此。 – ybungalobill 2012-03-05 18:22:45
@ybungalobill我會添加一個賞金,但我懷疑這會有所幫助。 – pmr 2012-03-06 12:01:25
[請注意,這是一個已知問題](https://svn.boost.org/trac/boost/ticket/1315)。另外我說的是錯的,有標準的迭代器從操作符*返回自己,但它們的value_type被定義爲'void'。 – ybungalobill 2012-03-06 12:05:04