함수 참조에 대한 또 다른 질문이 있습니다. 예를 들어 , 나는 그런 정의가 :함수 참조로 작업
typedef boost::function<bool (Entity &handle)> behaviorRef;
std::map< std::string, ptr_vector<behaviorRef> > eventAssociation;
되는 첫 번째 질문 : 어떻게 같은 맵 오브젝트에 값을 삽입하는?
내가 시도 :eventAssociation.insert(std::pair< std::string, ptr_vector<behaviorRef> >(eventType, ptr_vector<behaviorRef>(callback)));
그러나 오류 :
no matching function for call to ‘boost::ptr_vector<boost::function<bool(Entity&)> >::push_back(Entity::behaviorRef&)’
그리고 내가 undersatnd하지만, 실행 가능한 코드를 만들 수 없습니다.
두 번째 질문은 이러한 함수를 호출하는 방법입니다. 예를 들어, behaviorRef의 객체가 하나 있는데, boost :: bind으로 값을 전달하는 방법은 무엇입니까?
팁으로 직접 쌍을 구성하는 대신에'std :: make_pair()'를 사용할 수 있습니다. 이렇게하면 쌍의 템플리트 매개 변수를 작성하지 않아도됩니다. –
@ james-mcnellis 팁 주셔서 감사합니다! – Ockonal