Gennaro Prota wrote: > On Tue, 18 Feb 2003 19:14:50 +0200, "Rani Sharoni" > <[EMAIL PROTECTED]> wrote: > >> This is very nice technique. Just notice that you also need to >> handle void, functions and arrays types. >> >> Abstract classes, functions and array types will fail the completion >> on the burn conversion operator since they are not allowed as >> returns types. > > Yeah. The code was just to give the idea, which I could have expressed > in English if it wasn't that my English is even worse than my C++ :-) > > >> IMHO the main achievement of your technique is that, unlike >> techniques that use conversion constructor to burn user defined >> conversion, its works for incomplete classes (EDG and GCC complain >> when trying to pass lvalue of incomplete class to function that take >> ellipsis as an argument). > > Yes. Attempting lvalue-to-rvalue conversion of an expression of > incomplete type makes the program ill-formed.
Sure. 5.2.2/7. It's easy to overlook this case. > Nice :-) BTW, you can avoid the select_type machinery: Thanks > > template <typename T> > struct Burn { > operator T&() const; > }; > > // fire-prevention > template <typename T> > Burn<T> ref(T*); You can improve it to deal with qualified function types (you can't have pointers or references for such types): Burn<T> ref(T(*)[1]); > template <typename T> > char* ref(...); > > // outside the is_enum<> template > // to help gcc > // > yes is_enum_checker (unsigned long); > no is_enum_checker (...); > > > template <typename T> > struct is_enum { > > static const bool value = > !is_integral<T>::value > && !is_floating<T>::value > && sizeof(yes) == sizeof( is_enum_checker (ref<T>(0)) ); > }; > > > But this simple stuff is already enough to knock out a lot of > compilers :-/ > > BTW, I've seen how complex boost::is_reference is. Why so? What > compiler(s) cause(s) most problems? VC6 is problematic since the usual techniques to simulate partial specialization ICEd it. I remember that I came up with the same VC6 trick before I saw it in boost and I wonder who invented it. Rani _______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost