From: Vladimir Grigoriev on
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(


From: Alex Blekhman on
"Vladimir Grigoriev" wrote:
> Thank you, Igor, very much. I was trying to place [6] before the
> list of parameters and not at the end.:)

The common way to cope with such nasty declarations is to use
`typedef' keyword:

typedef char my_buff_t[6];

const my_buff_t& f(const my_buff_t& x, const my_buff_t& y);

This way you can pack the syntactic ugliness into nice descriptive
type names.

HTH
Alex

From: Vladimir Grigoriev on
Thanks Alex. I was trying to do the same but without using typedefs. So I
got errors.

Vladimir Grigoriev

"Alex Blekhman" <tkfx.REMOVE(a)yahoo.com> wrote in message
news:OJ4xsGUsKHA.732(a)TK2MSFTNGP06.phx.gbl...
> "Vladimir Grigoriev" wrote:
>> Thank you, Igor, very much. I was trying to place [6] before the list of
>> parameters and not at the end.:)
>
> The common way to cope with such nasty declarations is to use `typedef'
> keyword:
>
> typedef char my_buff_t[6];
>
> const my_buff_t& f(const my_buff_t& x, const my_buff_t& y);
>
> This way you can pack the syntactic ugliness into nice descriptive type
> names.
>
> HTH
> Alex