CLHEP VERSION Reference Documentation
   
CLHEP Home Page     CLHEP Documentation     CLHEP Bug Reports

testSharedPtrConvertible.cc

Go to the documentation of this file.
00001 // ======================================================================
00002 //
00003 // Test compilability and basic functionality of Utility/memory.h
00004 //
00005 // Author:  W. E. Brown, 2010-03-19, adapted from the boost library's
00006 // shared_ptr and related functionality whose internal attributions bear
00007 // the following various notices:
00008 //
00009 //   Copyright (c) 2008 Peter Dimov
00010 //   Distributed under the Boost Software License, Version 1.0.
00011 //   See http://www.boost.org/LICENSE_1_0.txt
00012 //
00013 // ======================================================================
00014 
00015 
00016 #include "CLHEP/Utility/noncopyable.h"
00017 #include "CLHEP/Utility/memory.h"
00018 
00019 #include <cassert>
00020 
00021 
00022 using namespace CLHEP;
00023 using CLHEP::shared_ptr;
00024 
00025 
00026 class incomplete;
00027 
00028 struct X
00029 { };
00030 
00031 struct Y
00032 { };
00033 
00034 struct Z: public X
00035 { };
00036 
00037 int f( shared_ptr<void const> )
00038 { return 1; }
00039 
00040 int f( shared_ptr<int> )
00041 { return 2; }
00042 
00043 int f( shared_ptr<incomplete> )
00044 { return 3; }
00045 
00046 int g( shared_ptr<X> )
00047 { return 4; }
00048 
00049 int g( shared_ptr<Y> )
00050 { return 5; }
00051 
00052 int g( shared_ptr<incomplete> )
00053 { return 6; }
00054 
00055 int main()
00056 {
00057   shared_ptr<double>  p1;
00058   assert( 1 == f( p1 ) );
00059   assert( 1 == f( shared_ptr<double>() ) );
00060 
00061   shared_ptr<Z>  p2;
00062   assert( 4 == g( p2 ) );
00063   assert( 4 == g( shared_ptr<Z>() ) );
00064 
00065   return 0;
00066 }

Generated on 15 Nov 2012 for CLHEP by  doxygen 1.4.7