T
Toon Knapen
Following small test-program (see below) compiles fine with multiple
versionS of gcc, icc, xlC, aCC, pathscale but not with the PGI compiler.
The PGI 6.1 compiler tells me following:
<error>
"test.cpp", line 12: error: more than one operator "<<" matches these
operands:
function "std:perator<<(std::basic_ostream<char,
std::char_traits<char>> &, const
std::complex<double> &)"
function "mine:perator<<(std:stream &, const
std::complex<double> &)"
operand types are: std:stream << std::complex<double>
std::cout << d << std::endl ;
^
1 error detected in the compilation of "test.cpp".
</error>
Now I'm wondering if PGI is right or all others are right? Due to Koenig
lookup the compiler logically is going to search in the std namespace
too so the error generated by PGI looks plausible.
Additionally, does anybody know of any unconforming behaviour of the PGI
compiler ?
Thanks,
toon
<test.cpp>
#include <complex>
#include <iostream>
namespace mine {
std:stream& operator<<(std:stream& os,std::complex<double> const & v)
{ std::cout << "mine:perator<<" << std::endl ; return os ; }
void foo()
{
std::complex<double> d ;
std::cout << d << std::endl ;
}
}
</test.cpp>
versionS of gcc, icc, xlC, aCC, pathscale but not with the PGI compiler.
The PGI 6.1 compiler tells me following:
<error>
"test.cpp", line 12: error: more than one operator "<<" matches these
operands:
function "std:perator<<(std::basic_ostream<char,
std::char_traits<char>> &, const
std::complex<double> &)"
function "mine:perator<<(std:stream &, const
std::complex<double> &)"
operand types are: std:stream << std::complex<double>
std::cout << d << std::endl ;
^
1 error detected in the compilation of "test.cpp".
</error>
Now I'm wondering if PGI is right or all others are right? Due to Koenig
lookup the compiler logically is going to search in the std namespace
too so the error generated by PGI looks plausible.
Additionally, does anybody know of any unconforming behaviour of the PGI
compiler ?
Thanks,
toon
<test.cpp>
#include <complex>
#include <iostream>
namespace mine {
std:stream& operator<<(std:stream& os,std::complex<double> const & v)
{ std::cout << "mine:perator<<" << std::endl ; return os ; }
void foo()
{
std::complex<double> d ;
std::cout << d << std::endl ;
}
}
</test.cpp>