
On 6/10/05, Arkadiy Vertleyb <vertleyb@hotmail.com> wrote:
"Peder Holt" <peder.holt@gmail.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
On 6/9/05, Arkadiy Vertleyb <vertleyb@hotmail.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.
As a user of typeof, I would certainly find this very useful. It allows the programmer to take evasive action if the typeof operation fails, by finding a suitable type in another way. #1 would not help me here. #2, on the other hand, allows me check if the type 'returned' by typeof is not_registered. If it is, one can programatically work around it. my suggestion would yield #2 Another useful feature, would be to detect if an expression is too complex. If an expression has a complexity>BOOST_TYPEOF_LIMIT_SIZE, typeof should 'return' boost::type_of::type_too_complex or similar. This can be achieved in a similar way to what I suggested earlier. Regards, Peder
Regards, Arkadiy
_______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost