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
30using namespace CLHEP;
32
33
34class incomplete;
35
36struct X
37{ };
38
39struct Y
40{ };
41
42struct Z: public X
43{ };
44
46{ return 1; }
47
49{ return 2; }
50
52{ return 3; }
53
55{ return 4; }
56
58{ return 5; }
59
61{ return 6; }
62
63int main()
64{
66 assert( 1 == f( p1 ) );
67 assert( 1 == f( shared_ptr<double>() ) );
68
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
std::shared_ptr< T > shared_ptr
Definition: memory.h:17
int f(shared_ptr< void const >)
int g(shared_ptr< X >)