Boost logo

Boost :

From: Jonathan Turkanis (technews_at_[hidden])
Date: 2004-01-22 23:09:14


"Daniel Wallin" <dalwan01_at_[hidden]> wrote in message
news:40106597.3090906_at_student.umu.se...
> Jonathan Turkanis wrote:

>
> Am I missing something?
>

No, I was. Thanks.

Here are some test cases. The ones marked error are cases I believe
should not compile.

    struct Base { virtual ~Base() { } };
    struct Derived : Base { };

    inline move_ptr<Derived> source() { return move_ptr<Derived>(new
Derived); }
    inline void sink(move_ptr<Base>) { }

    inline void const_sink(const move_ptr<Base> p)
    {
        /*[1]*/ move_ptr<Base> p2 = p; // ???
    }

    int main()
    {
        /*[2]*/ sink(source());
        /*[3]*/ sink(move_ptr<Derived>());
        /*[4]*/ sink(move_ptr<Base>());
        /*[5]*/ const_sink(source());
        /*[6]*/ const_sink(move_ptr<Derived>());
        /*[7]*/ move_ptr<Derived> p1(new Derived);
        /*[8]*/ move_ptr<Base> p2(new Derived);
        /*[9]*/ move_ptr<Derived> p3 = source();
        /*[10]*/ move_ptr<Base> p4 = source();
        /*[11]*/ move_ptr<Derived> p5(move_ptr<Derived>(new Derived));
        /*[12]*/ move_ptr<Base> p6(move_ptr<Derived>(new Derived));
        /*[13]*/ const move_ptr<Derived> p7(new Derived);

        /*[14]*/ move_ptr<Thing> p7(p3); // error
        /*[15]*/ move_ptr<Thing> p8(p3); // error
      }

Results from several compilers:

VC7.1 Rejects: 1, 14, 15
GCC 3.2 Rejects: 1, 14, 15
Codewarrior 8.0 Rejects: 14, 15
Como 4.3.3 online Rejects: 1, 14, 15
Como 4.3.3 jdt Rejects: 1, 2, 3, 5, 6, 10, 11, 12, 14, 15
Intel 7.1 Windows Rejects: 1, 2, 3, 5, 6, 10, 11, 12, 14, 15

As you can see, VC7.1, GCC 3.2 Codewarrior 8.0 and the latest como
almost agree. My como 4.3.3 from October and Intel reject a lot of
valid cases.

VC7.1, GCC 3.2 and como 4.3.3 reject 1, while Codewarrior accepts it.
I think it should fail to compile. Correct? It seems to be the only
case where the cant_move_from_const makes any difference.

What is your view?

Jonathan


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