?
=?iso-8859-2?q?Seweryn_Habdank-Wojew=F3dzki?=
Hi
There is an example of the code below (mostly written by P. Bindels).
In that example is strongly highlighted that very important is the
sequence
of compiled code. In C++ could be assume that such a sequence exists.
But the question is if it is a feature or it is a bug?
Especially in the scope of that example we could observe that
templates
can be somehow separated from its specializations.
Best regards.
#include <iostream>
template <class A>
class T {
A a;
};
class is_original_version_of_template
{
public:
static bool const value;
};
bool const is_original_version_of_template::value
(sizeof(T<void *>) == sizeof(T<void *>));
template <class A>
class T<A *> {
A *a[10];
};
class is_not_original_version_of_template // specialized
{
public:
static bool const value;
};
bool const is_not_original_version_of_template::value
(sizeof(T<void *>) == is_original_version_of_template::value);
int main()
{
std::cout << "is_original_version_of_template "
<< is_original_version_of_template::value << '\n';
std::cout << "is_not_original_version_of_template "
<< is_not_original_version_of_template::value << '\n';
}
There is an example of the code below (mostly written by P. Bindels).
In that example is strongly highlighted that very important is the
sequence
of compiled code. In C++ could be assume that such a sequence exists.
But the question is if it is a feature or it is a bug?
Especially in the scope of that example we could observe that
templates
can be somehow separated from its specializations.
Best regards.
#include <iostream>
template <class A>
class T {
A a;
};
class is_original_version_of_template
{
public:
static bool const value;
};
bool const is_original_version_of_template::value
(sizeof(T<void *>) == sizeof(T<void *>));
template <class A>
class T<A *> {
A *a[10];
};
class is_not_original_version_of_template // specialized
{
public:
static bool const value;
};
bool const is_not_original_version_of_template::value
(sizeof(T<void *>) == is_original_version_of_template::value);
int main()
{
std::cout << "is_original_version_of_template "
<< is_original_version_of_template::value << '\n';
std::cout << "is_not_original_version_of_template "
<< is_not_original_version_of_template::value << '\n';
}