Boost logo

Boost :

From: William Kempf (sirwillard_at_[hidden])
Date: 2000-10-02 14:39:57


(Sorry to leave so much of the original messages in this post, but
everything seems important to quote.)

--- In boost_at_[hidden], Mat Marcus <mmarcus_at_o...> wrote:
> At 7:56 AM -0400 10/2/00, David Abrahams wrote:
> >
> >
> >----- Original Message -----
> >From: "Mat Marcus" <mmarcus_at_o...>
> >
> >> Au contraire. I believe this is a key observation. Thanks! We
hadn't
> >> solved ISREF yet. In our work we've been using an ISCONST
> >> metafunction that uses IsNonConstPointer for a discriminator.
That is
> >> (roughly)
> >>
> >> char IsNonConstPointer(void*);
> >> int IsNonConstPointer(...);
> >>
> >> template <class T>
> >> struct ISCONST {
> >> enum {RET = (sizeof(IsNonConstPointer((T*)0)) == 1)}; //
The pointer
> >trick
> >> };
> >>
> >> If we combine this with your idea we could try
> >>
> > > template <class T>
> >> struct ISREF {
> >> enum {RET = sizeof(IsNonConstPointer(&((Holder<T>*)0)->x)
== 1)};
> >> };
> >>
> >
> >:( :( :(
> >
> >I don't think this will work. And VC6.3 bears me out:
> >
> >char IsNonConstPointer(void*);
> >int IsNonConstPointer(...);
> >
> >template <class T> struct Holder { T x; Holder(); };
> >
> >template <class T>
> >struct ISCONST {
> > enum {RET = (sizeof(IsNonConstPointer((T*)0)) == 1)}; // The
pointer
> >trick
> >};
> >
> >
> >template <class T>
> >struct ISREF {
> > enum {RET = sizeof(IsNonConstPointer(&((Holder<T>*)0)->x) ==
1)};
> >};

[snip]

> >Basically, it looks like ISREF<T>::RET is always true.
> >
> > > I can't wait to go to work to try this on my Windows compiler.
(Did I
> >> just say that? :-| ). Too bad Metrowerks' sizeof operator
doesn't
> >> work.

[snip]

> Monday morning, back at my Windows box. The above code seems to
work
> for me on VC6.3 after correcting some typos:
>
> template <class T>
> struct ISCONST {
> enum {RET = (1 != sizeof(&((Holder<T>*)0)->x))};
> };

I don't follow this at all. It appears that your ISCONST will always
return 'true' because you're basically doing a sizeof(T*) != 1 in the
above code. Trying to implement this in VC6 bears this out for me.
So, either you made some more typos here or I'm severely misreading
the posted code.
 
> Cool. One aspect of this version of ISREF is that there are no
> compiler warnings from VC6.3.

As opposed to which other version of ISREF?

I really want to find work arounds here, as I'd really, REALLY,
*REALLY* like a version of the Lambda Library that works for VC++.
So, I'm following this thread carefully and trying to get things to
work with VC6. Unfortunately, I'm still stumbling on a few things
here that others claim to have figured out.

Bill Kempf


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