map_abilitiesを持つActorクラスがあります
Actorクラスにはコピーコンストラクターがあり、この中にこのマップの機能を新しいアクターインスタンスにコピーしたいと思います。Abilityにはコピーコンストラクターもあります。
したがって、私の計画は、コピー元の渡されたアクターインスタンスの能力マップをループして、新しい能力を作成することでした。これを行うのは、各アビリティが実際にアクターを実行および変更するため、アクターをコピーするときに、そのすべてのアビリティの新しいインスタンスも必要になるためです。次のコードは、渡されたアクターアビリティをiterに割り当てようとすると、forループでエラーが発生します。
error C2679: binary '=' : no operator found which takes a right-hand operand of type 'std::_Tree_const_iterator<_Mytree>' (or there is no acceptable conversion)
1> with
1> [
1> _Mytree=std::_Tree_val<std::_Tmap_traits<std::string,Ability *,std::less<std::string>,std::allocator<std::pair<const std::string,Ability *>>,false>>
1> ]
1> c:\program files\microsoft visual studio 10.0\vc\include\xtree(429): could be 'std::_Tree_iterator<_Mytree> &std::_Tree_iterator<_Mytree>::operator =(const std::_Tree_iterator<_Mytree> &)'
1> with
1> [
1> _Mytree=std::_Tree_val<std::_Tmap_traits<std::string,Ability *,std::less<std::string>,std::allocator<std::pair<const std::string,Ability *>>,false>>
1> ]
1> while trying to match the argument list '(std::_Tree_iterator<_Mytree>, std::_Tree_const_iterator<_Mytree>)'
1> with
1> [
1> _Mytree=std::_Tree_val<std::_Tmap_traits<std::string,Ability *,std::less<std::string>,std::allocator<std::pair<const std::string,Ability *>>,false>>
1> ]
// _abilities define as
map<string, Ability*> _abilities;
Actor::Actor(const Actor& actor)
{
// make a copy of this actors model and stats
_model = CopyEntity(actor._model);
_stats = actor._stats;
// copy the abilities and assign this as the new actor
map<string, Ability*>::iterator iter;
for(iter = actor._abilities.begin(); iter != actor._abilities.end(); ++iter)
_abilities[(*iter).first] = new Ability(*(*iter).second, this);
}
なぜそれが私にこれをさせないのか理解できません。タイプは一致します。