mirror of
https://github.com/ETLCPP/etl.git
synced 2026-11-10 15:19:50 +08:00
* Fix histogram test Use different Start index so skipped start_index copy would not get unnoticed in the test. * Fix several test_vector_* for valid data Instead of comparing the moved-from data which is invalid, compare with the valid initial_data. * Fix test_vector to check for the correct iterator position after erase This was done before, but a recent change dropped it. * Fix bit_stream: Guard nbits > 0 to prevent division by zero * Cleanup --------- Co-authored-by: John Wellbelove <jwellbelove@users.noreply.github.com>
74 lines
1.3 KiB
Markdown
74 lines
1.3 KiB
Markdown
---
|
|
title: "packet"
|
|
---
|
|
|
|
A homogeneous container that can contain one of several types that are all inherited from the same base class.
|
|
|
|
```cpp
|
|
etl::packet<typename TBase, size_t SIZE, size_t ALIGNMENT>
|
|
```
|
|
|
|
## Template parameters
|
|
`TBase`
|
|
 The base class for all objects. The destructor must be virtual.
|
|
|
|
`SIZE`
|
|
 The size of the largest type.
|
|
|
|
`ALIGNMENT`
|
|
 The largest alignment of all of the types.
|
|
|
|
## Member types
|
|
|
|
`base_t` = `TBase`
|
|
|
|
## Constructors
|
|
|
|
**C++03**
|
|
```cpp
|
|
template <typename T>
|
|
explicit packet(const T& value)
|
|
```
|
|
|
|
**C++11**
|
|
```cpp
|
|
template <typename T>
|
|
explicit packet(T&& value)
|
|
```
|
|
**Description**
|
|
Constructs an object of type `T` with the supplied value.
|
|
Static asserts on any type that does not derive from `TBase`.
|
|
Static asserts on any type that does not conform to the maximum size and alignment.
|
|
|
|
## Destructor
|
|
```cpp
|
|
~packet()
|
|
```
|
|
**Description**
|
|
Destructs the contained object
|
|
|
|
## Operators
|
|
|
|
**C++03**
|
|
```cpp
|
|
template <typename T>
|
|
packet& operator =(const T& value)
|
|
```
|
|
|
|
**C++11**
|
|
```cpp
|
|
template <typename T>
|
|
packet& operator =(T&& value)
|
|
```
|
|
**Description**
|
|
Assigns a new object to the packet.
|
|
The previous object is destructed.
|
|
|
|
## Access
|
|
|
|
```cpp
|
|
const TBase& get() const
|
|
```
|
|
**Description**
|
|
Returns a const reference to the contained object.
|