Skip to content

Commit dfc88bd

Browse files
committed
Switch from booster::shared_ptr/weak_ptr to std::ones
Switch from auto_ptr to unique_ptr
1 parent de995ba commit dfc88bd

104 files changed

Lines changed: 410 additions & 2339 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

booster/CMakeLists.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -431,7 +431,6 @@ set(BOOSTER_SRC
431431
lib/aio/src/basic_socket.cpp
432432
lib/aio/src/acceptor.cpp
433433
lib/aio/src/stream_socket.cpp
434-
lib/smart_ptr/src/sp_counted_base.cpp
435434
lib/smart_ptr/src/atomic_counter.cpp
436435
lib/shared_object/src/shared_object.cpp
437436
lib/log/src/log.cpp
@@ -688,7 +687,6 @@ endif()
688687

689688
add_booster_test(smart_ptr shared_ptr)
690689
add_booster_test(smart_ptr atomic_counter)
691-
add_booster_test(smart_ptr sp_counter)
692690

693691
add_booster_test(log log)
694692
add_booster_test(nowide nowide)

booster/booster/aio/io_service.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
#include <booster/callback.h>
1818
#include <booster/noncopyable.h>
1919
#include <string>
20-
#include <booster/auto_ptr_inc.h>
20+
#include <memory>
2121

2222
namespace booster {
2323
class ptime;
@@ -137,7 +137,7 @@ namespace aio {
137137
private:
138138
struct data;
139139
hold_ptr<data> d;
140-
std::auto_ptr<event_loop_impl> impl_;
140+
std::unique_ptr<event_loop_impl> impl_;
141141
};
142142

143143
} // aio

booster/booster/aio/reactor.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#define BOOSTER_AIO_REACTOR_H
1010
#include <booster/config.h>
1111
#include <booster/aio/types.h>
12-
#include <booster/auto_ptr_inc.h>
12+
#include <memory>
1313
#include <string>
1414
namespace booster {
1515
namespace aio {
@@ -113,7 +113,7 @@ namespace aio {
113113
///
114114
std::string name() const;
115115
private:
116-
std::auto_ptr<reactor_impl> impl_;
116+
std::unique_ptr<reactor_impl> impl_;
117117
};
118118
} // aio
119119
} // booster

booster/booster/auto_ptr_inc.h

Lines changed: 0 additions & 24 deletions
This file was deleted.

booster/booster/bad_weak_ptr.h

Lines changed: 1 addition & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,4 @@
11
#ifndef BOOSTER_SMART_PTR_BAD_WEAK_PTR_HPP_INCLUDED
22
#define BOOSTER_SMART_PTR_BAD_WEAK_PTR_HPP_INCLUDED
3-
4-
//
5-
// boost/smart_ptr/bad_weak_ptr.hpp
6-
//
7-
// Copyright (c) 2001, 2002, 2003 Peter Dimov and Multi Media Ltd.
8-
//
9-
// Distributed under the Boost Software License, Version 1.0. (See
10-
// accompanying file LICENSE_1_0.txt or copy at
11-
// http://www.boost.org/LICENSE_1_0.txt)
12-
//
13-
14-
#include <booster/backtrace.h>
15-
16-
#ifdef __BORLANDC__
17-
# pragma warn -8026 // Functions with excep. spec. are not expanded inline
18-
#endif
19-
20-
namespace booster
21-
{
22-
23-
// The standard library that comes with Borland C++ 5.5.1, 5.6.4
24-
// defines std::exception and its members as having C calling
25-
// convention (-pc). When the definition of bad_weak_ptr
26-
// is compiled with -ps, the compiler issues an error.
27-
// Hence, the temporary #pragma option -pc below.
28-
29-
#if defined(__BORLANDC__) && __BORLANDC__ <= 0x564
30-
# pragma option push -pc
31-
#endif
32-
33-
///
34-
/// An exeption that is throws in case of creating of shared_ptr from expired weak_ptr
35-
///
36-
class bad_weak_ptr: public booster::exception
37-
{
38-
public:
39-
40-
virtual char const * what() const throw()
41-
{
42-
return "booster::bad_weak_ptr";
43-
}
44-
};
45-
46-
#if defined(__BORLANDC__) && __BORLANDC__ <= 0x564
47-
# pragma option pop
48-
#endif
49-
50-
} // namespace boost
51-
52-
#ifdef __BORLANDC__
53-
# pragma warn .8026 // Functions with excep. spec. are not expanded inline
54-
#endif
55-
3+
#include <booster/memory_inc.h>
564
#endif // #ifndef BOOST_SMART_PTR_BAD_WEAK_PTR_HPP_INCLUDED

booster/booster/callback.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#define BOOSTER_CALLBACK_H
1010

1111
#include <booster/backtrace.h>
12-
#include <booster/auto_ptr_inc.h>
12+
#include <memory>
1313
#include <booster/intrusive_ptr.h>
1414
#include <booster/refcounted.h>
1515

@@ -164,15 +164,15 @@ namespace booster {
164164
{} \
165165
\
166166
template<typename Call> \
167-
callback(std::auto_ptr<Call> ptr) : call_ptr(ptr.release()) \
167+
callback(std::unique_ptr<Call> ptr) : call_ptr(ptr.release()) \
168168
{} \
169169
\
170170
template<typename Call> \
171171
callback const &operator=(intrusive_ptr<Call> c) \
172172
{ call_ptr = c; return *this; } \
173173
\
174174
template<typename Call> \
175-
callback const &operator=(std::auto_ptr<Call> c) \
175+
callback const &operator=(std::unique_ptr<Call> c) \
176176
{ call_ptr = 0; call_ptr = c.release(); return *this; } \
177177
\
178178
template<typename F> \

booster/booster/checked_delete.h

Lines changed: 1 addition & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -1,65 +1,4 @@
11
#ifndef BOOSTER_CHECKED_DELETE_H
22
#define BOOSTER_CHECKED_DELETE_H
3-
4-
//
5-
// boost/checked_delete.hpp
6-
//
7-
// Copyright (c) 2002, 2003 Peter Dimov
8-
// Copyright (c) 2003 Daniel Frey
9-
// Copyright (c) 2003 Howard Hinnant
10-
//
11-
// Distributed under the Boost Software License, Version 1.0. (See
12-
// accompanying file LICENSE_1_0.txt or copy at
13-
// http://www.boost.org/LICENSE_1_0.txt)
14-
//
15-
// See http://www.boost.org/libs/utility/checked_delete.html for documentation.
16-
//
17-
18-
namespace booster
19-
{
20-
21-
/// \cond INTERNAL
22-
23-
// verify that types are complete for increased safety
24-
25-
template<class T> inline void checked_delete(T * x)
26-
{
27-
// intentionally complex - simplification causes regressions
28-
typedef char type_must_be_complete[ sizeof(T)? 1: -1 ];
29-
(void) sizeof(type_must_be_complete);
30-
delete x;
31-
}
32-
33-
template<class T> inline void checked_array_delete(T * x)
34-
{
35-
typedef char type_must_be_complete[ sizeof(T)? 1: -1 ];
36-
(void) sizeof(type_must_be_complete);
37-
delete [] x;
38-
}
39-
40-
template<class T> struct checked_deleter
41-
{
42-
typedef void result_type;
43-
typedef T * argument_type;
44-
45-
void operator()(T * x) const
46-
{
47-
// boost:: disables ADL
48-
booster::checked_delete(x);
49-
}
50-
};
51-
52-
template<class T> struct checked_array_deleter
53-
{
54-
typedef void result_type;
55-
typedef T * argument_type;
56-
57-
void operator()(T * x) const
58-
{
59-
booster::checked_array_delete(x);
60-
}
61-
};
62-
/// \endcond
63-
} // namespace boost
64-
3+
#include <booster/memory_inc.h>
654
#endif // #ifndef BOOST_CHECKED_DELETE_HPP_INCLUDED

booster/booster/clone_ptr.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
namespace booster {
1212

1313
///
14-
/// \brief a smart pointer similar to std::auto_ptr but it clones (by calling T::clone())
14+
/// \brief a smart pointer similar to std::unique_ptr but it clones (by calling T::clone())
1515
/// underlying object on copy instead of moving its ownership.
1616
///
1717
template<typename T>

booster/booster/copy_ptr.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
namespace booster {
1212

1313
///
14-
/// \brief a smart pointer similar to std::auto_ptr but it copies
14+
/// \brief a smart pointer similar to std::unique_ptr but it copies
1515
/// underlying object on pointer copy instead of moving its ownership.
1616
///
1717
/// Note: Underlying object has same constness as the pointer itself (not like in ordinary pointer).
Lines changed: 1 addition & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -1,85 +1,4 @@
11
#ifndef BOOSTER_SMART_PTR_ENABLE_SHARED_FROM_THIS_HPP_INCLUDED
22
#define BOOSTER_SMART_PTR_ENABLE_SHARED_FROM_THIS_HPP_INCLUDED
3-
4-
//
5-
// enable_shared_from_this.hpp
6-
//
7-
// Copyright 2002, 2009 Peter Dimov
8-
//
9-
// Distributed under the Boost Software License, Version 1.0.
10-
// See accompanying file LICENSE_1_0.txt or copy at
11-
// http://www.boost.org/LICENSE_1_0.txt
12-
//
13-
// http://www.boost.org/libs/smart_ptr/enable_shared_from_this.html
14-
//
15-
16-
#include <booster/weak_ptr.h>
17-
#include <booster/shared_ptr.h>
18-
#include <assert.h>
19-
#include <booster/config.h>
20-
21-
namespace booster
22-
{
23-
24-
///
25-
/// \brief This class is borrowed from boost
26-
///
27-
/// For details see: http://www.boost.org/doc/libs/release/libs/smart_ptr
28-
///
29-
30-
template<class T> class enable_shared_from_this
31-
{
32-
protected:
33-
34-
enable_shared_from_this()
35-
{
36-
}
37-
38-
enable_shared_from_this(enable_shared_from_this const &)
39-
{
40-
}
41-
42-
enable_shared_from_this & operator=(enable_shared_from_this const &)
43-
{
44-
return *this;
45-
}
46-
47-
~enable_shared_from_this()
48-
{
49-
}
50-
51-
public:
52-
53-
shared_ptr<T> shared_from_this()
54-
{
55-
shared_ptr<T> p( weak_this_ );
56-
assert( p.get() == this );
57-
return p;
58-
}
59-
60-
shared_ptr<T const> shared_from_this() const
61-
{
62-
shared_ptr<T const> p( weak_this_ );
63-
assert( p.get() == this );
64-
return p;
65-
}
66-
67-
public: // actually private, but avoids compiler template friendship issues
68-
69-
// Note: invoked automatically by shared_ptr; do not call
70-
template<class X, class Y> void _internal_accept_owner( shared_ptr<X> const * ppx, Y * py ) const
71-
{
72-
if( weak_this_.expired() )
73-
{
74-
weak_this_ = shared_ptr<T>( *ppx, py );
75-
}
76-
}
77-
78-
private:
79-
80-
mutable weak_ptr<T> weak_this_;
81-
};
82-
83-
} // namespace boost
84-
3+
#include <booster/memory_inc.h>
854
#endif // #ifndef BOOST_SMART_PTR_ENABLE_SHARED_FROM_THIS_HPP_INCLUDED

0 commit comments

Comments
 (0)