K
K. Frank
Hello Group!
I'm having trouble with "g++ -std=c++0x" when trying to compile
std::make_pair<int, unsigned> (i, u)
where I give explicit template arguments to make_pair, specifically:
#include <utility>
std:air<int, unsigned> f() {
int i = 1;
unsigned u = 2;
std:air <int, unsigned> p = std::make_pair<int, unsigned> (i,
u); // <-- legal?
// std:air <int, unsigned> p = std::make_pair (i, u); // <--
this works
return p;
}
This compiles fine when I just run "g++", but fails when I turn on
experimental support for the new standard, "g++ -std=c++0x",
giving the following error:
C:\>g++ -std=c++0x -c pair_junk2.cpp
pair_junk2.cpp: In function 'std:air<int, unsigned int> f()':
pair_junk2.cpp:5:68: error: no matching function for call to
'make_pair(int&, unsigned int&)'
pair_junk2.cpp:5:68: note: candidate is:
../lib/gcc/x86_64-w64-mingw32/4.7.0/../../../../include/c++/4.7.0/
bits/stl_pair.h:280:5: note: template<class _T1, class _T2> constexpr
std:air<typename std::__decay_and_strip<_T1>::__type, typename
std::__decay_and_strip<_T2>::__type> std::make_pair(_T1&&, _T2&&)
../lib/gcc/x86_64-w64-mingw32/4.7.0/../../../../include/c++/4.7.0/
bits/stl_pair.h:280:5: note: template argument deduction/
substitution failed:
pair_junk2.cpp:5:68: note: cannot convert 'i' (type 'int') to
type 'int&&'
I am running a mingw-w64 build of g++: "g++ (GCC) 4.7.0 20110829
(experimental)"
(For what it's worth, the code is accepted by Comeau's online
compiler.)
Is "std::make_pair<int, unsigned> (i, u)" legal in general? Is this
a difference between the old and new standards? Is this a bug
in g++ in std=c++0x mode?
Thanks.
K. Frank
I'm having trouble with "g++ -std=c++0x" when trying to compile
std::make_pair<int, unsigned> (i, u)
where I give explicit template arguments to make_pair, specifically:
#include <utility>
std:air<int, unsigned> f() {
int i = 1;
unsigned u = 2;
std:air <int, unsigned> p = std::make_pair<int, unsigned> (i,
u); // <-- legal?
// std:air <int, unsigned> p = std::make_pair (i, u); // <--
this works
return p;
}
This compiles fine when I just run "g++", but fails when I turn on
experimental support for the new standard, "g++ -std=c++0x",
giving the following error:
C:\>g++ -std=c++0x -c pair_junk2.cpp
pair_junk2.cpp: In function 'std:air<int, unsigned int> f()':
pair_junk2.cpp:5:68: error: no matching function for call to
'make_pair(int&, unsigned int&)'
pair_junk2.cpp:5:68: note: candidate is:
../lib/gcc/x86_64-w64-mingw32/4.7.0/../../../../include/c++/4.7.0/
bits/stl_pair.h:280:5: note: template<class _T1, class _T2> constexpr
std:air<typename std::__decay_and_strip<_T1>::__type, typename
std::__decay_and_strip<_T2>::__type> std::make_pair(_T1&&, _T2&&)
../lib/gcc/x86_64-w64-mingw32/4.7.0/../../../../include/c++/4.7.0/
bits/stl_pair.h:280:5: note: template argument deduction/
substitution failed:
pair_junk2.cpp:5:68: note: cannot convert 'i' (type 'int') to
type 'int&&'
I am running a mingw-w64 build of g++: "g++ (GCC) 4.7.0 20110829
(experimental)"
(For what it's worth, the code is accepted by Comeau's online
compiler.)
Is "std::make_pair<int, unsigned> (i, u)" legal in general? Is this
a difference between the old and new standards? Is this a bug
in g++ in std=c++0x mode?
Thanks.
K. Frank