H
Howard Gardner
/*
As it sits, this program won't compile for me. It will compile
using either of the versions of tpt that I've commented out.
Which versions SHOULD compile?
I think that the code is interesting because I think that it is
on the path to building a useful non-intrusive type introspection
facility. The version that uses "has" indicates the direction.
*/
#include <ostream>
#include <cstddef>
template< typename x >
x * faux_ptr();
//template< typename x, size_t = sizeof( int * ) >
// struct tpt{};
//template< typename x, size_t = sizeof( faux_ptr< int >() ) >
// struct tpt{};
//struct has{ int memvar; };
//template< typename x, size_t = sizeof( faux_ptr< has >()->memvar ) >
// struct tpt{};
template< typename x, size_t = sizeof( faux_ptr< x >() ) >
struct tpt{};
template< typename x >
bool fnc( tpt< x > );
tpt< int > inst;
size_t size = sizeof( fnc( inst ) );
int main()
{
using namespace std;
cout << size << endl;
}
As it sits, this program won't compile for me. It will compile
using either of the versions of tpt that I've commented out.
Which versions SHOULD compile?
I think that the code is interesting because I think that it is
on the path to building a useful non-intrusive type introspection
facility. The version that uses "has" indicates the direction.
*/
#include <ostream>
#include <cstddef>
template< typename x >
x * faux_ptr();
//template< typename x, size_t = sizeof( int * ) >
// struct tpt{};
//template< typename x, size_t = sizeof( faux_ptr< int >() ) >
// struct tpt{};
//struct has{ int memvar; };
//template< typename x, size_t = sizeof( faux_ptr< has >()->memvar ) >
// struct tpt{};
template< typename x, size_t = sizeof( faux_ptr< x >() ) >
struct tpt{};
template< typename x >
bool fnc( tpt< x > );
tpt< int > inst;
size_t size = sizeof( fnc( inst ) );
int main()
{
using namespace std;
cout << size << endl;
}