CLHEP
2.4.6.4
C++ Class Library for High Energy Physics
Loading...
Searching...
No Matches
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
#include <type_traits>
21
22
#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ > 6)
23
#pragma GCC diagnostic push
24
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
25
#elif __clang__
26
#pragma clang diagnostic push
27
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
28
#endif
29
30
using namespace
CLHEP
;
31
using
CLHEP::shared_ptr
;
32
33
34
class
incomplete;
35
36
struct
X
37
{ };
38
39
struct
Y
40
{ };
41
42
struct
Z
:
public
X
43
{ };
44
45
int
f
(
shared_ptr<void const>
)
46
{
return
1; }
47
48
int
f
(
shared_ptr<int>
)
49
{
return
2; }
50
51
int
f
(
shared_ptr<incomplete>
)
52
{
return
3; }
53
54
int
g
(
shared_ptr<X>
)
55
{
return
4; }
56
57
int
g
(
shared_ptr<Y>
)
58
{
return
5; }
59
60
int
g
(
shared_ptr<incomplete>
)
61
{
return
6; }
62
63
int
main
()
64
{
65
shared_ptr<double>
p1;
66
assert( 1 ==
f
( p1 ) );
67
assert( 1 ==
f
(
shared_ptr<double>
() ) );
68
69
shared_ptr<Z>
p2;
70
assert( 4 ==
g
( p2 ) );
71
assert( 4 ==
g
(
shared_ptr<Z>
() ) );
72
73
return
0;
74
}
75
76
#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ > 6)
77
#pragma GCC diagnostic pop
78
#elif __clang__
79
#pragma clang diagnostic pop
80
#endif
CLHEP
Definition:
DiagMatrix.h:23
CLHEP::shared_ptr
std::shared_ptr< T > shared_ptr
Definition:
memory.h:17
X
Definition:
testSharedPtrConvertible.cc:37
Y
Definition:
testSharedPtrConvertible.cc:40
Z
Definition:
testSharedPtrConvertible.cc:43
f
int f(shared_ptr< void const >)
Definition:
testSharedPtrConvertible.cc:45
main
int main()
Definition:
testSharedPtrConvertible.cc:63
g
int g(shared_ptr< X >)
Definition:
testSharedPtrConvertible.cc:54
CLHEP-CLHEP_2_4_6_4
Utility
test
testSharedPtrConvertible.cc
Generated by
1.9.6