11#ifndef NDARRAY_Manager_h_INCLUDED
12#define NDARRAY_Manager_h_INCLUDED
21#include <boost/noncopyable.hpp>
22#include <boost/intrusive_ptr.hpp>
23#include <boost/scoped_array.hpp>
27class Manager :
private boost::noncopyable {
30 typedef boost::intrusive_ptr<Manager> Ptr;
32 friend inline void intrusive_ptr_add_ref(
Manager const * manager) {
36 friend inline void intrusive_ptr_release(
Manager const * manager) {
37 if ((--manager->_rc)==0)
delete manager;
40 int getRC()
const {
return _rc; }
42 virtual bool isUnique()
const {
return false; }
56 typedef typename boost::remove_const<T>::type U;
59 static std::pair<Manager::Ptr,T*> allocate(Size size) {
60 boost::intrusive_ptr<SimpleManager> r(
new SimpleManager(size));
61 return std::pair<Manager::Ptr,T*>(r, r->_p.get());
64 virtual bool isUnique()
const {
return true; }
68 if (size > 0) _p.reset(
new U[size]);
70 boost::scoped_array<U> _p;
73template <
typename T> Manager::Ptr makeManager(T
const & owner);
80 template <
typename T>
friend Manager::Ptr makeManager(T
const & owner);
82 Owner
const & getOwner()
const {
return *
static_cast<Owner
const *
>(
this); }
89inline Manager::Ptr makeManager(T
const & owner) {
94inline Manager::Ptr makeManager(Manager::Ptr
const & owner) {
Forward declarations and default template parameters for ndarray.