
On 6/9/05, Arkadiy Vertleyb <vertleyb@hotmail.com> wrote:
"jarvi" <jarvi@cs.tamu.edu> wrote
The main point was that the result_of template needs to detect whether the BOOST_TYPEOF will succeed (all relevant types/templates have been typeof-registered), and if it will not succeed, then follow the list of steps specified in the TR1.
Well, I am afraid this might not be possible with current BOOST_TYPEOF --Types/templates not registerd just result in compile error :-(
Come to think about it, this doesn't have to stay this way. I havn't
it, but it seems possible to just put some well-known type in place of not-registered one, for example, something like this:
"std::pair<std::vector<boost::type_of::not_registered>, int>"
or maybe just
"boost::type_of::not_registered"
This way the fact that types are not registered can be used in meta-programs. The drawback -- it's unclear what's not registered. So maybe we need some sort of combination of both.
Again, *I think* it's possible, but I am not in a position to verify
"Peder Holt" <peder.holt@gmail.com> wrote tried this
until later in the evening... Is it something that would be of interest?
I did this once for the vintage implementation. Here is the technique I used: (Except I used function overloads...)
namespace boost {namespace type_of{ namespace {
struct not_registered_vector { typedef mpl::int_<1> item ## n; //For n=0 to BOOST_TYPEOF_LIMIT_SIZE };
template<typename T> struct push_back<not_registered_vector,T> { typedef not_registered_vector type; };
//Default implementation of encode_type_impl template<typename V,typename T> struct encode_type_impl { typedef uninitialized_type_vector type; };
struct not_registered {}; template<class Iter> struct decode_type_impl<mpl::size_t<1>, Iter> { typedef not_registered type; typedef Iter iter; };
}}
If we place this code in a separate header file, we can trigger compile errors on demand.
Actually what I meant is even simpler, something like: given desired results: 1) "std::pair<std::vector<boost::type_of::not_registered>, int>" 2) "boost::type_of::not_registered" namespace boost { namespace type_of { srtuct not_registered; }} BOOST_TYPEOF_REGISTER_TYPE(not_registered) namespace boost { namespace type_of { template<class V, class T> struct encode_type_impl // default impl { typedef typename encode_type_impl<V, not_registered>::type type; }; }} should achieve the result #1. To achieve the result #2 there seem to be a few alternatives. But again, I would first like to know if this would be useful. Regards, Arkadiy