[cfe-commits] [libcxx] r111747 - in /libcxx/trunk: include/memory test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/auto_pointer.pass.cpp

Eli Friedman eli.friedman at gmail.com
Sat Aug 21 14:40:40 PDT 2010


On Sat, Aug 21, 2010 at 2:14 PM, Howard Hinnant <hhinnant at apple.com> wrote:
> Modified: libcxx/trunk/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/auto_pointer.pass.cpp
> URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/auto_pointer.pass.cpp?rev=111747&r1=111746&r2=111747&view=diff
> ==============================================================================
> --- libcxx/trunk/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/auto_pointer.pass.cpp (original)
> +++ libcxx/trunk/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/auto_pointer.pass.cpp Sat Aug 21 16:14:53 2010
> @@ -1 +1 @@
> -//===----------------------------------------------------------------------===//
> //
> //                     The LLVM Compiler Infrastructure
> //
> // This file is distributed under the University of Illinois Open Source
> // License. See LICENSE.TXT for details.
> //
> //===----------------------------------------------------------------------===//
>
> // <memory>
>
> // unique_ptr
>
> // Test unique_ptr(pointer) ctor
>
> #include <memory>
> #include <cassert>
>
> // template <class U> explicit unique_ptr(auto_ptr<U>&);
>
> struct A
> {
>    static int count;
>    A() {++count;}
>    A(const A&) {++count;}
>    virtual ~A() {--count;}
> };
>
> int A::count = 0;
>
> struct B
>    : public A
> {
>    static int count;
>    B() {++count;}
>    B(const B&) {++count;}
>    virtual ~B() {--count;}
> };
>
> int B::count = 0;
>
> int main()
> {
>    {
>    B* p = new B;
>    std::auto_ptr<B> ap(p);
>    std::unique_ptr<A> up(ap);
>    assert(up.get() == p);
>    assert(ap.get() == 0);
>    assert(A::count == 1);
>    assert(B::count == 1);
>    }
>
>  assert(A::count == 0);
>    assert(B::count == 0);
>    {
>    B* p = new B;
>    std::auto_ptr<B> ap(p);
>    std::unique_ptr<A> up;
>    up = ap;
>    assert(up.get() == p);
>    assert(ap.get() == 0);
>    assert(A::count == 1);
>    assert(B::count == 1);
>    }
>    assert(A::count == 0);
>    assert(B::count == 0);
>    {
>    B* p = new B;
>    std::auto_ptr<B> ap(p);
>    std::unique_ptr<A> up;
>    up = std::move(ap);
>    assert(up.get() == p);
>    assert(ap.get() == 0);
>    assert(A::count == 1);
>    assert(B::count == 1);
>    }
>    assert(A::count == 0);
>    assert(B::count == 0);
> }
> \ No newline at end of file
> +//===----------------------------------------------------------------------===//
> //
> //                     The LLVM Compiler Infrastructure
> //
> // This file is distributed under the University of Illinois Open Source
> // License. See LICENSE.TXT for details.
> //
> //===----------------------------------------------------------------------===//
>
> // <memory>
>
> // unique_ptr
>
> // Test unique_ptr(pointer) ctor
>
> #include <memory>
> #include <cassert>
>
> // template <class U> explicit unique_ptr(auto_ptr<U>&);
>
> struct A
> {
>    static int count;
>    A() {++count;}
>    A(const A&) {++count;}
>    virtual ~A() {--count;}
> };
>
> int A::count = 0;
>
> struct B
>    : public A
> {
>    static int count;
>    B() {++count;}
>    B(const B&) {++count;}
>    virtual ~B() {--count;}
> };
>
> int B::count = 0;
>
> int main()
> {
>    {
>    B* p = new B;
>    std::auto_ptr<B> ap(p);
>    std::unique_ptr<A> up(std::move(ap));
>    assert(up.get() == p);
>    assert(ap.get() == 0);
>    assert(A::count == 1);
>    assert(B::count == 1);
>
>    }
>    assert(A::count == 0);
>    assert(B::count == 0);
>    {
>    B* p = new B;
>    std::auto_ptr<B> ap(p);
>    std::unique_ptr<A> up;
>    up = std::move(ap);
>    assert(up.get() == p);
>    assert(ap.get() == 0);
>    assert(A::count == 1);
>    assert(B::count == 1);
>    }
>    assert(A::count == 0);
>    assert(B::count == 0);
> }
> \ No newline at end of file

The line-endings here look screwy; a quick "grep -RP "\r" libcxx
--include=*.cpp | wc -l" shows there are 580 files with Mac-style line
endings.

-Eli




More information about the cfe-commits mailing list