[Insight-developers] C++11 make_pair() isn't compatible with the uses of 'make_pair<const std::string, std::string>(tag, value)'

nmgzjf at gmail.com nmgzjf at gmail.com
Sun Sep 29 21:35:39 EDT 2013


Hi,



These days, I want to use ITK 4.4.2. When I compiled the code by using VS2010, it was OK. But, when I used VS2012, there was an error which said 'InsightApplications\MRIBiasCorrection\OptionList.cxx(37): error C2664: 'std::make_pair' : cannot convert parameter 1 from 'std::string' to 'const std::string &&'' and 'You cannot bind an lvalue to an rvalue reference'. Firstly I wanted to find the answer of this problem by using Google, but I cann't get anything. Then I found a similar problem on the page 'http://connect.microsoft.com/VisualStudio/feedback/details/691756/std-make-pair-error-in-vc11'. I followed the answer, and revised the code, then the it worked very well. 



And I use the following codes for test, if you use VS2010, it will work well. But, there will be an error if you use VS 2012. 



#include<string>
#include<utility>
#include<iostream>
using namespace std;

int main() {
 string ht = "hello";
 pair<double,string> ps;
 ps = make_pair<int,string>(1,ht);

 int index = 1 ;
 char* argv[] = {"A","B"};
 std::string tag ;

 const std::string value = argv[index] ;
 
 std::make_pair<const std::string, std::string>(tag, value) ;//zjf

 cout << ps.first << " " << ps.second << endl;
 return 0;
}



I hope this can help someone who uses the VS2012 to bind VTK 4.4.2.

发自 Windows 邮件
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-developers/attachments/20130930/aa47ea4d/attachment.htm>


More information about the Insight-developers mailing list