Boost logo

Boost :

From: rwgk (rwgk_at_[hidden])
Date: 2002-02-05 19:24:01


--- In boost_at_y..., "Andrei Alexandrescu" <andrewalex_at_h...> wrote:
> > I should confess that I've never thought about that. I have no
idea
> > if it's possible to implement it in such a way without using
dynamic
> > allocation.
>
> www.oonumerics.org/tmpw01/alexandrescu.pdf

Extracting the relevant information from this paper is not easy.
Could you please help?

I am working on an array family for numeric applications.
Here is a fragment of my equivalent of the proposed
fixed_capacity_vector:

  template <typename ElementType, std::size_t N>
  class small_plain
  {
    public:
      ElementType elems[N];

      small_plain() { m_size = 0; }
      explicit
      small_plain(std::size_t n) { m_size = n; }

      ElementType* begin() { return elems; }

      //...

    private:
      std::size_t m_size;
  };

What would I have to do to avoid construction of the N elements?
Instead of
      ElementType elems[N];
would I have
      char_with_align<ElementType> char_like_elems[N];
?
What would my begin() do? Something like
      ElementType* begin() { reinterpret_cast<ElementType>
char_like_elems; }
?

Would you have example source code that is not too
convoluted with other concepts?

Thanks,
        Ralf


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk