मुझे समझ नहीं आता क्यों यह (विजुअल C++ 2012) काम नहीं करता:क्यों बढ़ावा :: असाइन :: list_of जोड़ी <स्ट्रिंग, वेक्टर <string>> के साथ काम नहीं कर रहा है?
#include <string>
#include <utility>
#include <vector>
#include <boost/assign/list_of.hpp>
using namespace std;
int main()
{
pair<string, vector<string> >("^", boost::assign::list_of<string>("rules"));
}
त्रुटि है:
include\utility(138) : error C2668: 'std::vector<_Ty>::vector' : ambiguous call to overloaded function with [ _Ty=std::string ]
include\vector(786): could be 'std::vector<_Ty>::vector(std::vector<_Ty> &&)' with [ _Ty=std::string ]
include\vector(693): or 'std::vector<_Ty>::vector(unsigned int)' with [ _Ty=std::string ]
while trying to match the argument list '(boost::assign_detail::generic_list<T>)' with [ T=std::string ]
test.cpp(12) : see reference to function template instantiation 'std::pair<_Ty1,_Ty2>::pair<const char(&)[2],boost::assign_detail::generic_list<T>>(_Other1,_Other2 &&,void **)' being compiled
with
[
_Ty1=std::string,
_Ty2=std::vector<std::string>,
T=std::string,
_Other1=const char (&)[2],
_Other2=boost::assign_detail::generic_list<std::string>
]
test.cpp(12) : see reference to function template instantiation 'std::pair<_Ty1,_Ty2>::pair<const char(&)[2],boost::assign_detail::generic_list<T>>(_Other1,_Other2 &&,void **)' being compiled
with
[
_Ty1=std::string,
_Ty2=std::vector<std::string>,
T=std::string,
_Other1=const char (&)[2],
_Other2=boost::assign_detail::generic_list<std::string>
]
मैं समझने नहीं क्यों यह एक unsigned int
अधिभार का उपयोग करने की कोशिश कर रहा है ... कोई विचार?
क्योंकि टेम्पलेट कन्स्ट्रक्टर भी उपयुक्त नहीं है। आज़माएं: जोड़ी <स्ट्रिंग, वेक्टर> ("^", boost :: असाइन :: list_of (std :: string ("नियम")); या जोड़ी <स्ट्रिंग, वेक्टर > ("^", boost :: असाइन :: list_of ("नियम")); –
kassak
@ डाउनवॉटर: डाउनवोट क्यों? – Mehrdad
@ कसक: क्यों 'हस्ताक्षरित int' क्यों? मुझे समस्या के आसपास काम करने में बहुत परेशानी नहीं है, बल्कि यह समझना कि यह पहली जगह क्यों हो रहा है। – Mehrdad