Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <utility>
- #include <iostream>
- #include <vector>
- #include <string>
- int main ( )
- {
- std::string s = "abc";
- // 1 ok
- std::pair < std::string, int > a = std::make_pair ( s, 7 );
- // 2 error on the next line
- std::pair < std::string, int > b = std::make_pair < std::string, int > ( s, 7 );
- // 3 ok
- std::pair < std::string, int > d = std::pair < std::string, int > ( s, 7 );
- return 0;
- }
- test.cpp: In function ‘int main()’:
- test.cpp:11:83: error: no matching function for call to ‘make_pair(std::string&, int)’
- test.cpp:11:83: note: candidate is:
- In file included from /gcc4.7/usr/local/lib/gcc/i686-pc-linux-gnu/4.7.0/../../../../include/c++/4.7.0/utility:72:0,
- from test.cpp:1:
- /gcc4.7/usr/local/lib/gcc/i686-pc-linux-gnu/4.7.0/../../../../include/c++/4.7.0/bits/stl_pair.h:274:5:
- note: template<class _T1, class _T2> constexpr std::pair<typename std::__decay_and_strip<_T1>::__type, typename std::__decay_and_strip<_T2>::__type> std::make_pair(_T1&&, _T2&&)
- /gcc4.7/usr/local/lib/gcc/i686-pc-linux-gnu/4.7.0/../../../../include/c++/4.7.0/bits/stl_pair.h:274:5:
- note: template argument deduction/substitution failed:
- test.cpp:11:83: note: cannot convert ‘s’ (type ‘std::string {aka std::basic_string<char>}’) to type ‘std::basic_string<char>&&’
- template <typename T, typename U>
- [return type] make_pair(T&& argT, U&& argU);
- [return type] make_pair(std::string&& argT, int&& argU);
- make_pair(s, 7)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement