Loading...
Searching...
No Matches
juce::CopyableHeapBlock< ElementType, throwOnFailure > Class Template Reference

## Detailed Description

template<typename ElementType, bool throwOnFailure = false>
class juce::CopyableHeapBlock< ElementType, throwOnFailure >

Wraps a HeapBlock, but additionally provides a copy constructor and remembers its size.

This class is not intended for use as a general-purpose container - in most cases, a std::vector or juce::Array is a better choice. However, CopyableHeapBlock may be handy for optimisation in situations where the container elements don't need to be value-initialised and the container doesn't need to be resized.

See also
  Array, OwnedArray, MemoryBlock, HeapBlock

The documentation for this class was generated from the following file:

- juce_core/memory/juce_CopyableHeapBlock.h

## Public Member Functions

| CopyableHeapBlock ()=default
| Creates an empty block.
| CopyableHeapBlock (size_t numElementsIn)
| Creates a block large enough to hold the specified number of elements.
| CopyableHeapBlock (CopyableHeapBlock &&other) noexcept
| Moves the contents of another block into this one.
| CopyableHeapBlock (const CopyableHeapBlock &other)
| Copies the contents of another block into this one.
CopyableHeapBlock & | operator= (CopyableHeapBlock &&other) noexcept
| Moves the contents of another block into this one.
CopyableHeapBlock & | operator= (const CopyableHeapBlock &other) noexcept
| Copies the contents of another block into this one.
ElementType * | data ()
| Returns a pointer to the first element in the block.
const ElementType * | data () const
| Returns a pointer to the first element in the block.
size_t | size () const
| Returns the number of elements in the block.
bool | isEmpty () const
| Returns true if the size of the block is zero.
ElementType * | begin ()
| Returns a pointer to the first element in the block.
const ElementType * | begin () const
| Returns a pointer to the first element in the block.
const ElementType * | cbegin () const
| Returns a pointer to the first element in the block.
ElementType * | end ()
| Returns a pointer immediately after the last element in the block.
const ElementType * | end () const
| Returns a pointer immediately after the last element in the block.
const ElementType * | cend () const
| Returns a pointer immediately after the last element in the block.
ElementType & | operator[] (size_t index)
| Returns a reference to the element at the provided index.
const ElementType & | operator[] (size_t index) const
| Returns a reference to the element at the provided index.

## Constructors and Destructors

## CopyableHeapBlock() [1/4]

template<typename ElementType, bool throwOnFailure = false>

juce::CopyableHeapBlock< ElementType, throwOnFailure >::CopyableHeapBlock | ( |  | ) |

default

Creates an empty block.

Referenced by CopyableHeapBlock(), CopyableHeapBlock(), operator=(), and operator=().

## CopyableHeapBlock() [2/4]

template<typename ElementType, bool throwOnFailure = false>

juce::CopyableHeapBlock< ElementType, throwOnFailure >::CopyableHeapBlock | ( | size_t | numElementsIn | ) |

inline explicit

Creates a block large enough to hold the specified number of elements.

The contents of the block are unspecified, and must be written before they are first read.

## CopyableHeapBlock() [3/4]

template<typename ElementType, bool throwOnFailure = false>

juce::CopyableHeapBlock< ElementType, throwOnFailure >::CopyableHeapBlock | ( | CopyableHeapBlock< ElementType, throwOnFailure > && | other | ) |

inline noexcept

Moves the contents of another block into this one.

References CopyableHeapBlock().

## CopyableHeapBlock() [4/4]

template<typename ElementType, bool throwOnFailure = false>

juce::CopyableHeapBlock< ElementType, throwOnFailure >::CopyableHeapBlock | ( | const CopyableHeapBlock< ElementType, throwOnFailure > & | other | ) |

inline

Copies the contents of another block into this one.

References CopyableHeapBlock().

## Member Functions

## operator=() [1/2]

template<typename ElementType, bool throwOnFailure = false>

CopyableHeapBlock & juce::CopyableHeapBlock< ElementType, throwOnFailure >::operator= | ( | CopyableHeapBlock< ElementType, throwOnFailure > && | other | ) |

inline noexcept

Moves the contents of another block into this one.

References CopyableHeapBlock().

## operator=() [2/2]

template<typename ElementType, bool throwOnFailure = false>

CopyableHeapBlock & juce::CopyableHeapBlock< ElementType, throwOnFailure >::operator= | ( | const CopyableHeapBlock< ElementType, throwOnFailure > & | other | ) |

inline noexcept

Copies the contents of another block into this one.

References CopyableHeapBlock().

## data() [1/2]

template<typename ElementType, bool throwOnFailure = false>

ElementType * juce::CopyableHeapBlock< ElementType, throwOnFailure >::data | ( |  | ) |

inline

Returns a pointer to the first element in the block.

Referenced by begin(), begin(), cbegin(), cend(), end(), end(), operator[](), and operator[]().

## data() [2/2]

template<typename ElementType, bool throwOnFailure = false>

const ElementType * juce::CopyableHeapBlock< ElementType, throwOnFailure >::data | ( |  | ) | const

inline

Returns a pointer to the first element in the block.

## size()

template<typename ElementType, bool throwOnFailure = false>

size_t juce::CopyableHeapBlock< ElementType, throwOnFailure >::size | ( |  | ) | const

inline

Returns the number of elements in the block.

Referenced by cend(), end(), end(), and isEmpty().

## isEmpty()

template<typename ElementType, bool throwOnFailure = false>

bool juce::CopyableHeapBlock< ElementType, throwOnFailure >::isEmpty | ( |  | ) | const

inline

Returns true if the size of the block is zero.

References size().

## begin() [1/2]

template<typename ElementType, bool throwOnFailure = false>

ElementType * juce::CopyableHeapBlock< ElementType, throwOnFailure >::begin | ( |  | ) |

inline

Returns a pointer to the first element in the block.

References data().

## begin() [2/2]

template<typename ElementType, bool throwOnFailure = false>

const ElementType * juce::CopyableHeapBlock< ElementType, throwOnFailure >::begin | ( |  | ) | const

inline

Returns a pointer to the first element in the block.

References data().

## cbegin()

template<typename ElementType, bool throwOnFailure = false>

const ElementType * juce::CopyableHeapBlock< ElementType, throwOnFailure >::cbegin | ( |  | ) | const

inline

Returns a pointer to the first element in the block.

References data().

## end() [1/2]

template<typename ElementType, bool throwOnFailure = false>

ElementType * juce::CopyableHeapBlock< ElementType, throwOnFailure >::end | ( |  | ) |

inline

Returns a pointer immediately after the last element in the block.

References data(), and size().

## end() [2/2]

template<typename ElementType, bool throwOnFailure = false>

const ElementType * juce::CopyableHeapBlock< ElementType, throwOnFailure >::end | ( |  | ) | const

inline

Returns a pointer immediately after the last element in the block.

References data(), and size().

## cend()

template<typename ElementType, bool throwOnFailure = false>

const ElementType * juce::CopyableHeapBlock< ElementType, throwOnFailure >::cend | ( |  | ) | const

inline

Returns a pointer immediately after the last element in the block.

References data(), and size().

## operator[]() [1/2]

template<typename ElementType, bool throwOnFailure = false>

ElementType & juce::CopyableHeapBlock< ElementType, throwOnFailure >::operator[] | ( | size_t | index | ) |

inline

Returns a reference to the element at the provided index.

References data().

## operator[]() [2/2]

template<typename ElementType, bool throwOnFailure = false>

const ElementType & juce::CopyableHeapBlock< ElementType, throwOnFailure >::operator[] | ( | size_t | index | ) | const

inline

Returns a reference to the element at the provided index.

References data().

### Purchase

Get JUCE

### Discover

What's New in JUCE Features

### Learn

Documentaion Tutorials Made with JUCE Resources

### Support

JUCE Forum Newsletter Archive

### About

Contact Us JUCE Legal JUCE Licensing FAQ

### Events

Audio Developer Conference
© Raw Material Software Limited