Boost logo

Boost :

From: Peder Holt (peder.holt_at_[hidden])
Date: 2005-06-10 01:23:29


On 6/9/05, Arkadiy Vertleyb <vertleyb_at_[hidden]> wrote:
> "jarvi" <jarvi_at_[hidden]> 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 tried
> 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 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.

Regards,
Peder

>
> Regards,
> Arkadiy
>
> Regards,
> Arkadiy
>
>
>
> _______________________________________________
> Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
>


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk