Boost logo

Boost :

From: Peder Holt (peder.holt_at_[hidden])
Date: 2005-09-01 03:59:37

On 9/1/05, David Abrahams <dave_at_[hidden]> wrote:
> Eric Niebler <eric_at_[hidden]> writes:
> > Ah. But the fact remains that remove_pointer et al. are indeed broken on
> > VC6 and VC7, and the regression tests bear this out.
> >
> >
> >
> > IMO, the best path is to preserve the meaning of
> > PTS. That is, it still defines full specializations of the type traits
> > templates. But the typeof implementation should be what the primary
> > template uses for compilers without PTS. That way, everything that is
> > working now, keeps working with no change in performance.
> I think it would better to do some actual speed testing there. After
> all, using the typeof hack *could* turn out to be much faster and use
> fewer resources than doing it the other way.
> It's a pretty easy test.

I don't think using the typeof library directly is the best idea. When
using typeof, you represent each type by a number, limiting you to
~1000 types.
Here, though, we have more information. In stead of using an integral
number to 'register' a type, we can use the input type:

        template<typename InputType>
        struct msvc_extract_type

            struct id2type;

        template<typename RegisteredType, typename InputType>
        struct msvc_register_type : msvc_typeof_base<InputType>
            struct msvc_typeof_base<InputType>::id2type // This uses
nice VC6-VC7 bugfeature
                typedef RegisteredType type;


template<typename U>
struct remove_pointer {
   template<typename T>
   msvc_register_type<T,remove_pointer<T*> > remove_ptr_fn(T* (*)())
   static U test_function();
   enum {register_type=sizeof(remove_ptr_fn(test_function))};
   typedef typename msvc_extract_type<remove_pointer<U> >::id2type::type type;

I'll try to get a version up and going with this implementation very soon.

> --
> Dave Abrahams
> Boost Consulting
> _______________________________________________
> Unsubscribe & other changes:

Boost list run by bdawes at, gregod at, cpdaniel at, john at