OpenCores
URL https://opencores.org/ocsvn/openrisc_me/openrisc_me/trunk

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [gcc-4.5.1/] [libstdc++-v3/] [testsuite/] [20_util/] [shared_ptr/] [creation/] [dr925.cc] - Blame information for rev 424

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 424 jeremybenn
// { dg-options "-std=gnu++0x -Wno-deprecated" }
2
 
3
// Copyright (C) 2010 Free Software Foundation
4
//
5
// This file is part of the GNU ISO C++ Library.  This library is free
6
// software; you can redistribute it and/or modify it under the
7
// terms of the GNU General Public License as published by the
8
// Free Software Foundation; either version 3, or (at your option)
9
// any later version.
10
 
11
// This library is distributed in the hope that it will be useful,
12
// but WITHOUT ANY WARRANTY; without even the implied warranty of
13
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
// GNU General Public License for more details.
15
 
16
// You should have received a copy of the GNU General Public License along
17
// with this library; see the file COPYING3.  If not see
18
// <http://www.gnu.org/licenses/>.
19
 
20
// 20.9.11.2 Template class shared_ptr [util.smartptr.shared]
21
 
22
#include <memory>
23
#include <testsuite_hooks.h>
24
 
25
struct A
26
{
27
};
28
 
29
std::unique_ptr<A>
30
create_unique_ptr()
31
{
32
  return std::unique_ptr<A>(new A());
33
}
34
 
35
std::auto_ptr<A>
36
create_auto_ptr()
37
{
38
  return std::auto_ptr<A>(new A());
39
}
40
 
41
void
42
process(std::shared_ptr<A> a)
43
{
44
  bool test __attribute__((unused)) = true;
45
 
46
  VERIFY( a.get() != 0 );
47
  VERIFY( a.use_count() == 1 );
48
}
49
 
50
// 20.9.11.2.1 shared_ptr creation [util.smartptr.shared.const]
51
 
52
// Implicit conversion of auto_ptr to shared_ptr is allowed
53
 
54
void
55
test01()
56
{
57
  process(create_auto_ptr());
58
}
59
 
60
void
61
test02()
62
{
63
  std::auto_ptr<A> a = create_auto_ptr();
64
  process(std::move(a));
65
}
66
 
67
// Implicit conversion of unique_ptr to shared_ptr is allowed
68
 
69
void
70
test03()
71
{
72
  process(create_unique_ptr());
73
}
74
 
75
void
76
test04()
77
{
78
  std::unique_ptr<A> a = create_unique_ptr();
79
  process(std::move(a));
80
}
81
 
82
int
83
main()
84
{
85
  test01();
86
  test02();
87
  test03();
88
  test04();
89
  return 0;
90
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.