CLHEP VERSION Reference Documentation
CLHEP Home Page
CLHEP Documentation
CLHEP Bug Reports
Utility
test
testSharedPtrConvertible.cc
Go to the documentation of this file.
1
// ======================================================================
2
//
3
// Test compilability and basic functionality of Utility/memory.h
4
//
5
// Author: W. E. Brown, 2010-03-19, adapted from the boost library's
6
// shared_ptr and related functionality whose internal attributions bear
7
// the following various notices:
8
//
9
// Copyright (c) 2008 Peter Dimov
10
// Distributed under the Boost Software License, Version 1.0.
11
// See http://www.boost.org/LICENSE_1_0.txt
12
//
13
// ======================================================================
14
15
16
#include "CLHEP/Utility/noncopyable.h"
17
#include "CLHEP/Utility/memory.h"
18
19
#include <cassert>
20
21
22
using namespace
CLHEP
;
23
using
CLHEP::shared_ptr
;
24
25
26
class
incomplete
;
27
28
struct
X
29
{ };
30
31
struct
Y
32
{ };
33
34
struct
Z
:
public
X
35
{ };
36
37
int
f
(
shared_ptr<void const>
)
38
{
return
1; }
39
40
int
f
(
shared_ptr<int>
)
41
{
return
2; }
42
43
int
f
(
shared_ptr<incomplete>
)
44
{
return
3; }
45
46
int
g
(
shared_ptr<X>
)
47
{
return
4; }
48
49
int
g
(
shared_ptr<Y>
)
50
{
return
5; }
51
52
int
g
(
shared_ptr<incomplete>
)
53
{
return
6; }
54
55
int
main
()
56
{
57
shared_ptr<double>
p1;
58
assert( 1 ==
f
( p1 ) );
59
assert( 1 ==
f
(
shared_ptr<double>
() ) );
60
61
shared_ptr<Z>
p2;
62
assert( 4 ==
g
( p2 ) );
63
assert( 4 ==
g
(
shared_ptr<Z>
() ) );
64
65
return
0;
66
}
CLHEP::shared_ptr
Definition:
Utility/Utility/memory.h:815
incomplete
Definition:
testWeakPtr.cc:1377
CLHEP
Definition:
ClhepVersion.h:13
X
Definition:
testSharedPtrBasic.cc:28
Y
Definition:
testSharedPtrBasic.cc:35
Z
Definition:
testSharedPtrConvertible.cc:35
f
int f(shared_ptr< void const >)
Definition:
testSharedPtrConvertible.cc:37
main
int main()
Definition:
testSharedPtrConvertible.cc:55
g
int g(shared_ptr< X >)
Definition:
testSharedPtrConvertible.cc:46
Generated by
1.9.1