あいまいな質問のタイトルで申し訳ありませんが、ここにこれらの typedef があります。
typedef std::list<AnimationKeyframe> Timeline;
typedef Timeline::iterator Keyframe;
そして、次のようなクラスを考えてみましょう:
class foo
{
Timeline timeline;
Keyframe left,right;
};
私はイテレータを保存しているので(悪い考えのようです)、コピー/代入コンストラクタも持っていますが、問題はそこにあります。
Keyframe myTemp, hisTemp;
this->left = this->timeline.begin(); // assigns
myTemp = this->timeline.begin(); // assigns
hisTemp = that.timeline.begin() // does not assign
「それ」の 1 つ (もう 1 つの foo) をキーフレームに割り当てようとするとすぐに、あいまいさの問題のようなエラーが発生します。
バイナリ '=' : タイプ 'std::_List_const_iterator<_Mylist>' の右側のオペランドを取る演算子が見つかりません (または、受け入れ可能な変換がありません)
追加情報:
with
[
_Mylist=std::_List_val<AnimationKeyframe,std::allocator<AnimationKeyframe>>
]
could be 'std::_List_iterator<_Mylist> &std::_List_iterator<_Mylist>::operator =(const std::_List_iterator<_Mylist> &)'
with
[
_Mylist=std::_List_val<AnimationKeyframe,std::allocator<AnimationKeyframe>>
]
while trying to match the argument list '(Keyframe, std::_List_const_iterator<_Mylist>)'
with
[
_Mylist=std::_List_val<AnimationKeyframe,std::allocator<AnimationKeyframe>>
]
この奇妙な動作の原因は何ですか? イテレータを状態として使用する私の悪いスタイルを疑っています...しかし、ポインターを保持する以外に、他にどのようにできるかわかりません。