Boost logo

Boost :

Subject: [boost] [array] Custom constructr/destructor
From: Kasra (kasra_n500_at_[hidden])
Date: 2009-07-18 11:45:28


I have found an interesting problem regardin using custom allocators/deallocators for an array object.

Say for example you want to initialise the array to some values and on destruction you want to do something with these values. This at the memoment is not possible. The solution is to create a new class which inherits from array.

template<class T, std::size_t N>
 class array;

template<class T, std::size_t N>
class my_array:
  public array<T,N>
   my_array() { ... }
   ~my_array() { ... }

Which is not an ideal solution and results in code bloat. However a defenition like bellow:

template<class T, std::size_t N, class PredCtor, class PredDtor>
class array;

Means the same code could be used for custom operations during construction and destruction.

Is there any interest in such a change? If so maybe we could propose this for the standard.

Yours truly,
-- Kasra

Boost list run by bdawes at, gregod at, cpdaniel at, john at