File: testSharedPtrConvertible.cc

package info (click to toggle)
clhep 2.1.4.1%2Bdfsg-1.1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 10,012 kB
  • sloc: cpp: 50,094; sh: 6,694; makefile: 2,694; perl: 28
file content (66 lines) | stat: -rw-r--r-- 1,238 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
// ======================================================================
//
// Test compilability and basic functionality of Utility/memory.h
//
// Author:  W. E. Brown, 2010-03-19, adapted from the boost library's
// shared_ptr and related functionality whose internal attributions bear
// the following various notices:
//
//   Copyright (c) 2008 Peter Dimov
//   Distributed under the Boost Software License, Version 1.0.
//   See http://www.boost.org/LICENSE_1_0.txt
//
// ======================================================================


#include "CLHEP/Utility/noncopyable.h"
#include "CLHEP/Utility/memory.h"

#include <cassert>


using namespace CLHEP;
using CLHEP::shared_ptr;


class incomplete;

struct X
{ };

struct Y
{ };

struct Z: public X
{ };

int f( shared_ptr<void const> )
{ return 1; }

int f( shared_ptr<int> )
{ return 2; }

int f( shared_ptr<incomplete> )
{ return 3; }

int g( shared_ptr<X> )
{ return 4; }

int g( shared_ptr<Y> )
{ return 5; }

int g( shared_ptr<incomplete> )
{ return 6; }

int main()
{
  shared_ptr<double>  p1;
  assert( 1 == f( p1 ) );
  assert( 1 == f( shared_ptr<double>() ) );

  shared_ptr<Z>  p2;
  assert( 4 == g( p2 ) );
  assert( 4 == g( shared_ptr<Z>() ) );

  return 0;
}