Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/boost_1_34_1/libs/python/pyste/tests/smart_ptr.h @ 45

Last change on this file since 45 was 29, checked in by landauf, 17 years ago

updated boost from 1_33_1 to 1_34_1

File size: 958 bytes
Line 
1/* Copyright Bruno da Silva de Oliveira 2003. Use, modification and
2 distribution is subject to the Boost Software License, Version 1.0.
3 (See accompanying file LICENSE_1_0.txt or copy at
4 http:#www.boost.org/LICENSE_1_0.txt)
5 */
6
7#ifndef SMART_PTR_H
8#define SMART_PTR_H
9
10
11#include <memory>
12#include <boost/shared_ptr.hpp>
13
14namespace smart_ptr {
15   
16struct C
17{
18    int value;
19};
20
21inline boost::shared_ptr<C> NewC() { return boost::shared_ptr<C>( new C() ); }
22
23struct D
24{
25    boost::shared_ptr<C> Get() { return ptr; }
26    void Set( boost::shared_ptr<C> c ) { ptr = c; }
27private:   
28    boost::shared_ptr<C> ptr;
29};
30
31inline std::auto_ptr<D> NewD() { return std::auto_ptr<D>( new D() ); }
32
33
34// test an abstract class
35struct A
36{
37    virtual int f() = 0;
38};
39
40struct B: A
41{
42    virtual int f(){ return 1; }
43};
44
45inline boost::shared_ptr<A> NewA() { return boost::shared_ptr<A>(new B()); }
46inline int GetA(boost::shared_ptr<A> a) { return a->f(); }
47
48}
49
50#endif
Note: See TracBrowser for help on using the repository browser.