[cfe-dev] Explicit template arguments in std::make_pair

Krzysztof Parzyszek via cfe-dev cfe-dev at lists.llvm.org
Thu Nov 16 09:20:35 PST 2017


This simple program fails to compile with -std=c++11, but compiles ok 
with c++03. This seems consistent between libc++/libstdc++. Is this due 
to a change in the standard? What is the reason behind it?

#include <utility>

std::pair<int,unsigned> good(unsigned L) {
   return std::make_pair(0, L);

std::pair<int,unsigned> bad(unsigned L) {
   return std::make_pair<int,unsigned>(0, L);

clang++ -c -std=c++11 pp.cpp -stdlib=libc++
pp.cpp:8:10: error: no matching function for call to 'make_pair'
   return std::make_pair<int,unsigned>(0, L);
/w/c/org/bin/../include/c++/v1/utility:639:1: note: candidate function not
       viable: no known conversion from 'unsigned int' to 'unsigned int 
&&' for
       2nd argument
make_pair(_T1&& __t1, _T2&& __t2)
1 error generated.


Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, 
hosted by The Linux Foundation

More information about the cfe-dev mailing list