Boost logo

Boost :

From: David Abrahams (dave_at_[hidden])
Date: 2004-01-05 15:36:09


"Jonathan Turkanis" <technews_at_[hidden]> writes:

> "David Abrahams" <dave_at_[hidden]> wrote in message
> news:ur7yep3t5.fsf_at_boost-consulting.com...
>> "Jonathan Turkanis" <technews_at_[hidden]> writes:
>>
>> >> Fixed now in CVS.
>> >>
>> >
>> > Cool! Now I can get rid of my crzy workarounds. Thanks.
>>
>> Did I mention that it was a terrible EDG bug?
>>
>
> Yeah, you said that's what it probably was. Now that you know what was going
> wrong, can you think of a simple example (i.e., not using any library code)
> which illustrates the problem?

template <class T> struct type_wrapper {};

template<typename T>
char
has_tag_helper(
    type_wrapper<T>const volatile*
  , type_wrapper<typename T::tag>* =0
);

int
has_tag_helper(...);
 
template<typename T>
struct has_tag
{
    typedef type_wrapper<T> t_;
 
    static const bool value=sizeof(
        (has_tag_helper)(static_cast<t_*>(0)))
        ;

};

template <class T> struct xx;
template <class T> struct yy { typedef T::type type; };
    
enum
{
    a = has_tag<xx<yy<int> > >::value
};
--------

Notice that preceding the use of has_tag_helper with :: seems to
suppress the bug.

-- 
Dave Abrahams
Boost Consulting
www.boost-consulting.com

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