default01.pass.cpp revision bc8d3f97eb5c958007f2713238472e0c1c8fe02c
16cda3e604f2a2fa289cc9145719ba84461315e21Douglas Gregor//===----------------------------------------------------------------------===//
2b65f2425e9847d30bae499323a2d5cc29808d0b5Douglas Gregor//
3b65f2425e9847d30bae499323a2d5cc29808d0b5Douglas Gregor// ��������������������The LLVM Compiler Infrastructure
4b65f2425e9847d30bae499323a2d5cc29808d0b5Douglas Gregor//
5b65f2425e9847d30bae499323a2d5cc29808d0b5Douglas Gregor// This file is distributed under the University of Illinois Open Source
6b65f2425e9847d30bae499323a2d5cc29808d0b5Douglas Gregor// License. See LICENSE.TXT for details.
7b65f2425e9847d30bae499323a2d5cc29808d0b5Douglas Gregor//
85e5783180acb42c9d9b1be2838370ea5930a2a8bAnders Carlsson//===----------------------------------------------------------------------===//
95e5783180acb42c9d9b1be2838370ea5930a2a8bAnders Carlsson
105e5783180acb42c9d9b1be2838370ea5930a2a8bAnders Carlsson// <memory>
115e5783180acb42c9d9b1be2838370ea5930a2a8bAnders Carlsson
12ea1471e0e967548c596a71469702f8846dbaf3c0John McCall// unique_ptr
13ea1471e0e967548c596a71469702f8846dbaf3c0John McCall
14ea1471e0e967548c596a71469702f8846dbaf3c0John McCall// Test unique_ptr default ctor
15ea1471e0e967548c596a71469702f8846dbaf3c0John McCall
16ea1471e0e967548c596a71469702f8846dbaf3c0John McCall#include <memory>
17ea1471e0e967548c596a71469702f8846dbaf3c0John McCall#include <cassert>
18ea1471e0e967548c596a71469702f8846dbaf3c0John McCall
19ea1471e0e967548c596a71469702f8846dbaf3c0John McCall// default unique_ptr ctor should only require default Deleter ctor
20ea1471e0e967548c596a71469702f8846dbaf3c0John McCallclass Deleter
21ea1471e0e967548c596a71469702f8846dbaf3c0John McCall{
22ea1471e0e967548c596a71469702f8846dbaf3c0John McCall    int state_;
23ea1471e0e967548c596a71469702f8846dbaf3c0John McCall
24ea1471e0e967548c596a71469702f8846dbaf3c0John McCall    Deleter(Deleter&);
25ea1471e0e967548c596a71469702f8846dbaf3c0John McCall    Deleter& operator=(Deleter&);
26ea1471e0e967548c596a71469702f8846dbaf3c0John McCall
27ea1471e0e967548c596a71469702f8846dbaf3c0John McCallpublic:
28ea1471e0e967548c596a71469702f8846dbaf3c0John McCall    Deleter() : state_(5) {}
29ea1471e0e967548c596a71469702f8846dbaf3c0John McCall
30ea1471e0e967548c596a71469702f8846dbaf3c0John McCall    int state() const {return state_;}
31ea1471e0e967548c596a71469702f8846dbaf3c0John McCall
32ea1471e0e967548c596a71469702f8846dbaf3c0John McCall    void operator()(void*) {}
33ea1471e0e967548c596a71469702f8846dbaf3c0John McCall};
34ea1471e0e967548c596a71469702f8846dbaf3c0John McCall
35ea1471e0e967548c596a71469702f8846dbaf3c0John McCall
36ea1471e0e967548c596a71469702f8846dbaf3c0John McCallint main()
37ea1471e0e967548c596a71469702f8846dbaf3c0John McCall{
38ea1471e0e967548c596a71469702f8846dbaf3c0John McCall    {
39ea1471e0e967548c596a71469702f8846dbaf3c0John McCall    std::unique_ptr<int> p;
40ea1471e0e967548c596a71469702f8846dbaf3c0John McCall    assert(p.get() == 0);
41ea1471e0e967548c596a71469702f8846dbaf3c0John McCall    }
42ea1471e0e967548c596a71469702f8846dbaf3c0John McCall    {
43ea1471e0e967548c596a71469702f8846dbaf3c0John McCall    std::unique_ptr<int, Deleter> p;
447925561e702430c0d632c5e5db1a74673b44ea18Fariborz Jahanian    assert(p.get() == 0);
457925561e702430c0d632c5e5db1a74673b44ea18Fariborz Jahanian    assert(p.get_deleter().state() == 5);
467925561e702430c0d632c5e5db1a74673b44ea18Fariborz Jahanian    }
477925561e702430c0d632c5e5db1a74673b44ea18Fariborz Jahanian}
487925561e702430c0d632c5e5db1a74673b44ea18Fariborz Jahanian