Opened 21 years ago
Closed 19 years ago
#944 closed Feature Requests (Fixed)
smart_ptrs: Custom allocators.
| Reported by: | murrayc | Owned by: | Peter Dimov | 
|---|---|---|---|
| Milestone: | Component: | smart_ptr | |
| Version: | None | Severity: | |
| Keywords: | Cc: | 
Description
I'd like to use the shared_ptr smart pointer, but the
underlying types that I am using have their own
specific *_alloc() and *_drop() functions instead of
using new/delete.
If the smart_ptr template classes took an allocator
type as a template arg then we would just have to
define our own allocators for things like this. By
using a default allocator that used new/delete there
would be no impact on current code.
e.g.
template< typename T, typename
Tallocator=default_allocator<T>>
class shared_ptr {};
Maybe the default_allocator<> is a bit like
std::allocator<>, but I'm not sure about that.
This would reduce the code for a lot of C-API wrapper
projects.
      Change History (3)
comment:2 by , 20 years ago
Logged In: NO I think that the concept "allocator" can be used not only for the smart_ptr templates. It should be used on every place where a template parameter can accept a pair of functions/methods that perform a resource allocation and release. Other examples for this: - create / destroy - fopen / fclose - login / logout - lock / unlock (http://www.boost.org/libs/thread/doc/mutex_concept.html)
comment:3 by , 19 years ago
| Status: | assigned → closed | 
|---|
  Note:
 See   TracTickets
 for help on using tickets.
    
