diff options
Diffstat (limited to 'test/utilities/memory/util.smartptr/util.smartptr.enab/enable_shared_from_this.pass.cpp')
-rw-r--r-- | test/utilities/memory/util.smartptr/util.smartptr.enab/enable_shared_from_this.pass.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/test/utilities/memory/util.smartptr/util.smartptr.enab/enable_shared_from_this.pass.cpp b/test/utilities/memory/util.smartptr/util.smartptr.enab/enable_shared_from_this.pass.cpp index 595d05c28..d4618719c 100644 --- a/test/utilities/memory/util.smartptr/util.smartptr.enab/enable_shared_from_this.pass.cpp +++ b/test/utilities/memory/util.smartptr/util.smartptr.enab/enable_shared_from_this.pass.cpp @@ -1 +1 @@ -//===----------------------------------------------------------------------===//
//
// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// template<class T>
// class enable_shared_from_this
// {
// protected:
// enable_shared_from_this();
// enable_shared_from_this(enable_shared_from_this const&);
// enable_shared_from_this& operator=(enable_shared_from_this const&);
// ~enable_shared_from_this();
// public:
// shared_ptr<T> shared_from_this();
// shared_ptr<T const> shared_from_this() const;
// };
#include <memory>
#include <cassert>
struct T
: public std::enable_shared_from_this<T>
{
};
struct Y : T {};
struct Z : Y {};
int main()
{
{
std::shared_ptr<Y> p(new Z);
std::shared_ptr<T> q = p->shared_from_this();
assert(p == q);
assert(!p.owner_before(q) && !q.owner_before(p)); // p and q share ownership
}
{
std::shared_ptr<Y> p = std::make_shared<Z>();
std::shared_ptr<T> q = p->shared_from_this();
assert(p == q);
assert(!p.owner_before(q) && !q.owner_before(p)); // p and q share ownership
}
}
\ 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.
//
//===----------------------------------------------------------------------===//
// template<class T>
// class enable_shared_from_this
// {
// protected:
// enable_shared_from_this();
// enable_shared_from_this(enable_shared_from_this const&);
// enable_shared_from_this& operator=(enable_shared_from_this const&);
// ~enable_shared_from_this();
// public:
// shared_ptr<T> shared_from_this();
// shared_ptr<T const> shared_from_this() const;
// };
#include <memory>
#include <cassert>
struct T
: public std::enable_shared_from_this<T>
{
};
struct Y : T {};
struct Z : Y {};
int main()
{
{
std::shared_ptr<Y> p(new Z);
std::shared_ptr<T> q = p->shared_from_this();
assert(p == q);
assert(!p.owner_before(q) && !q.owner_before(p)); // p and q share ownership
}
{
std::shared_ptr<Y> p = std::make_shared<Z>();
std::shared_ptr<T> q = p->shared_from_this();
assert(p == q);
assert(!p.owner_before(q) && !q.owner_before(p)); // p and q share ownership
}
}
\ No newline at end of file |