Vladimir Grigoriev
2010-02-18 16:44:20 UTC
Let consider the following template function
template <typename T>
const T & f( const T &x, const T &y )
{
std::cout << typeid( x ).name() << std::endl;
std::cout << typeid( y ).name() << std::endl;
return ( x );
}
When I run this function using Borland C++ compiler adding the statements
char s1[] = "ABCDE";
char s2[] = "GFHIJ";
std::cout << typeid( f( d1, s2 ) ).name() << std::endl;
I get the result
const char *
conts char *
const char *
When I run the code using Microsoft C++ 2005 EE I get
char const [6]
char const [6]
char const [6]
So it is interesting what should be displayed?
And if Microsoft C++ shows that the return value of f() is of type char
const [6] when how does look the corresponding instantiated function?
Vladimir Grigoriev
std::cout << typeid( f(
template <typename T>
const T & f( const T &x, const T &y )
{
std::cout << typeid( x ).name() << std::endl;
std::cout << typeid( y ).name() << std::endl;
return ( x );
}
When I run this function using Borland C++ compiler adding the statements
char s1[] = "ABCDE";
char s2[] = "GFHIJ";
std::cout << typeid( f( d1, s2 ) ).name() << std::endl;
I get the result
const char *
conts char *
const char *
When I run the code using Microsoft C++ 2005 EE I get
char const [6]
char const [6]
char const [6]
So it is interesting what should be displayed?
And if Microsoft C++ shows that the return value of f() is of type char
const [6] when how does look the corresponding instantiated function?
Vladimir Grigoriev
std::cout << typeid( f(