
Hi, It compiles fine but the result is wrong if the member type is not POD. Forcing the resolution to use the "test( ... )" nested function yields the following compiler error : test.cpp(23) : error C2770: invalid explicit template argument(s) for 'has_type_to_test<T>::yes has_type_to_test<T>::test(has_type_to_test<T>::Helper<U,&U::value> *)' Here is the test code that I ran, simplifying your code to try and track down the pb: #include <iostream> /* * under VC7.1, if type_to_test is not a POD, the output * will be "false", else it will be "true". * * If the test( ... ) is commented out to force use of the * test( Helper<U, &U::value> * ) resolution, the VC7.1 will output * the following error message: * * test.cpp(23) : error C2770: invalid explicit template argument(s) for * 'has_type_to_test<T>::yes has_type_to_test<T>::test(has_type_to_test<T>::Helper<U,&U::value> *)' */ #if 0 // Changing this to 1 will yield a wrong output. class type_to_test { }; #else typedef int type_to_test; #endif /** * introspection */ template< typename T > struct has_type_to_test { private: typedef char no; typedef struct { no _[2]; } yes; template< typename U, type_to_test U::* > struct Helper; template< typename U > static yes test( Helper<U, &U::value> * ); template< typename U > static no test( ... ); public: static bool const result = (sizeof(yes) == sizeof(test<T>(0))); }; /** * dummy test structure. */ struct test_structure { type_to_test value; }; /** * main prog. */ int main( ) { std::cout << "has_type_to_test<test_structure>::result == " << std::boolalpha << has_type_to_test<test_structure>::result << "\n"; std::getchar(); return 0; } This codes compiles fine under gcc 4.x.x and yields the correct result as well. Don't hesitate if you have any other questions, Regards, Olivier. On Fri, Oct 24, 2008 at 6:06 PM, Joel Falcou <joel.falcou@u-psud.fr> wrote:
Olivier Grant a écrit :
Hi, I was playing around with the introspection lib and it doesn't seem to work for public members that are not of POD type with Visual 7.1
Any idea how to work around that ?
Thanks,
Olivier.
Thanks for reporting. THose were predictable so i'll take extra-care at solvign those. I don't have access to VC7.1, only to VC8. Does it fail to compile or does it returns incorrec results ? If the former, care to post error messages ? If the later, care to post a code I can compile on VC ?
Thanks in advance
_______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost