27
私が取り組んでいるプロジェクトでは、C++サブプロジェクトからCocoa通知を送る必要があります。その上のメインプロジェクト。これを行うには、通知のuserInfoディクショナリのキー値ストアとして動作するマップを作成します。プロジェクトの一つで 未定義テンプレートの暗黙的なインスタンス化 'std :: basic_string <char、std :: char_traits <char>、std :: allocator >'
は、次のコードはうまくコンパイル:std::map<std::string, std::string> *userInfo = new std::map<std::string, std::string>;
char buffer[255];
sprintf(buffer, "%i", intValue1);
userInfo->insert(std::pair<std::string, std::string>("intValue1", std::string(buffer)));
sprintf(buffer, "%i", intValue2);
userInfo->insert(std::pair<std::string, std::string>("intValue2", std::string(buffer)));
if(condition)
userInfo->insert(std::pair<std::string, std::string>("conditionalValue", "true"));
PostCocoaNotification("notificationName", *userInfo);
をしかし、これは別のサブプロジェクトで同じファイルにコピーされている場合、コンパイラは> userInfo-に、次のスロー呼び出しを挿入します。
"Implicit instantiation of undefined template 'std::basic_string<char, std::char_traits<char>, std::allocator<char> >'"
..andそれはPostCocoaNotificationのための機能を見つけることができません。
No matching function for call to 'PostCocoaNotification'
さらに、それはシステムヘッダに次のエラーがスローされます。
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.1.sdk/usr/include/c++/4.2.1/bits/stl_pair.h:73:11: Implicit instantiation of undefined template 'std::basic_string<char, std::char_traits<char>, std::allocator<char> >'
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.1.sdk/usr/include/c++/4.2.1/bits/stl_pair.h:74:11: Implicit instantiation of undefined template 'std::basic_string<char, std::char_traits<char>, std::allocator<char> >'
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.1.sdk/usr/include/c++/4.2.1/bits/stl_pair.h:73:11: Implicit instantiation of undefined template 'std::basic_string<char, std::char_traits<char>, std::allocator<char> >'
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.1.sdk/usr/include/c++/4.2.1/bits/stl_tree.h:1324:13: Cannot initialize a parameter of type '_Link_type' (aka '_Rb_tree_node<std::pair<const std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::basic_string<char, std::char_traits<char>, std::allocator<char> > > > *') with an rvalue of type '_Const_Link_type' (aka 'const _Rb_tree_node<std::pair<const std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::basic_string<char, std::char_traits<char>, std::allocator<char> > > > *')
私は(成功した送信コードは別のサブプロジェクトに完全に正常に動作する場合は特に、そのような混乱を引き起こすために何をやったかさっぱりだが通知)。この問題に対する洞察は非常に歓迎されます。
私の最初の推測では、あなたが何かを含める必要があるということです。おそらくペア(ユーティリティ)または文字列のヘッダー。 – Kindread
私は 'string'も推測しています – doctorlove
私は文字列ヘッダーが犯人ではないと思います。userInfoが初期化されている行(' std :: map * telemetry = new std: :map ; ')はエラーを投げません。 –
Andrew