Boost logo

Boost :

From: Tomas Rapkauskas (slidertom_at_[hidden])
Date: 2007-01-04 08:08:51


Hello,
I just extended this test case
with struct derived2 and made function call() as virtual.
Question: should function test output "2"?
if no: how to get this(2) result?
I don't think that developer should make a call using "this->" in the
struct derived.

Modified test case:

template< class T >
struct base {
    virtual int call() {
        return 1;
    }
};

int call() {
    return 0;
}

template< class T >
struct derived : base< T > {
    int call_test() {
        return call();
    }
};

template< class T >
struct derived2 : derived< T > {
     virtual int call() {
        return 2;
    }
};

int test()
{
    derived2< int > d;
    return d.call_test();
}

Tomas

AlisdairM wrote:
> I have just supplied John with a new defect macro and test case to
> detect compilers that (do not) support 2-phase name lookup with
> templates, but it would be really helpful if someone who is more
> familiar with the problem (and access to conforming compilers!) can
> verify the test for us!
>
> The test case is in
>
> boost/libs/config/boost_no_two_phase_name_lookup.ipp
>
> and currently the code looks like:
>
> template< class T >
> struct base {
> int call() {
> return 1;
> }
> };
>
> int call() {
> return 0;
> }
>
> template< class T >
> struct derived : base< T > {
> int call_test() {
> return call();
> }
> };
>
> int test()
> {
> derived< int > d;
> return d.call_test();
> }
>
>
> I believe a conforming compiler should only find the 'free' function,
> where a broken compiler will typically call the function from its base
> class template.
>
>
> Also, beware of config test failures until the various compiler config
> headers are updated. This should also give us a good idea of whether
> the right compilers are being flagged!
>


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