D
Dave
Hello all,
Please see the question embedded in the code below. Thanks in advance for
your help!
Dave
#include <iostream>
using namespace std;
void foo(const char p[5])
{
// This yields char const * due to decay.
cout << "Non-template: " << typeid(p).name() << endl;
}
template <typename T>
void foo(T *p)
{
// This yields char; WHY NOT char const ????
cout << "Template: " << typeid(T).name() << endl;
// This yields char const *
cout << "Template: " << typeid(T *).name() << endl;
}
int main()
{
// This yields char const [5]. In sync with page 19 of the Standard;
cool...
cout << typeid("test").name() << endl;
foo("test");
foo<>("test");
}
Please see the question embedded in the code below. Thanks in advance for
your help!
Dave
#include <iostream>
using namespace std;
void foo(const char p[5])
{
// This yields char const * due to decay.
cout << "Non-template: " << typeid(p).name() << endl;
}
template <typename T>
void foo(T *p)
{
// This yields char; WHY NOT char const ????
cout << "Template: " << typeid(T).name() << endl;
// This yields char const *
cout << "Template: " << typeid(T *).name() << endl;
}
int main()
{
// This yields char const [5]. In sync with page 19 of the Standard;
cool...
cout << typeid("test").name() << endl;
foo("test");
foo<>("test");
}