---
title: llarp::AlignedBuffer
summary: aligned buffer that is sz bytes long and aligns to the nearest Alignment 

---

# llarp::AlignedBuffer



aligned buffer that is sz bytes long and aligns to the nearest Alignment  [More...](#detailed-description)


`#include <aligned.hpp>`

## Public Types

|                | Name           |
| -------------- | -------------- |
| using std::array< byte_t, SIZE > | **[Data](Classes/structllarp_1_1AlignedBuffer.md#using-data)**  |

## Public Functions

|                | Name           |
| -------------- | -------------- |
| virtual | **[~AlignedBuffer](Classes/structllarp_1_1AlignedBuffer.md#function-~alignedbuffer)**() =default |
| | **[AlignedBuffer](Classes/structllarp_1_1AlignedBuffer.md#function-alignedbuffer)**() |
| | **[AlignedBuffer](Classes/structllarp_1_1AlignedBuffer.md#function-alignedbuffer)**(const byte_t * data) |
| | **[AlignedBuffer](Classes/structllarp_1_1AlignedBuffer.md#function-alignedbuffer)**(const Data & buf) |
| [AlignedBuffer](Classes/structllarp_1_1AlignedBuffer.md) & | **[operator=](Classes/structllarp_1_1AlignedBuffer.md#function-operator=)**(const byte_t * data) |
| [AlignedBuffer](Classes/structllarp_1_1AlignedBuffer.md)< sz > | **[operator~](Classes/structllarp_1_1AlignedBuffer.md#function-operator~)**() const<br>bitwise NOT  |
| bool | **[operator==](Classes/structllarp_1_1AlignedBuffer.md#function-operator==)**(const [AlignedBuffer](Classes/structllarp_1_1AlignedBuffer.md) & other) const |
| bool | **[operator!=](Classes/structllarp_1_1AlignedBuffer.md#function-operator!=)**(const [AlignedBuffer](Classes/structllarp_1_1AlignedBuffer.md) & other) const |
| bool | **[operator<](Classes/structllarp_1_1AlignedBuffer.md#function-operator<)**(const [AlignedBuffer](Classes/structllarp_1_1AlignedBuffer.md) & other) const |
| bool | **[operator>](Classes/structllarp_1_1AlignedBuffer.md#function-operator>)**(const [AlignedBuffer](Classes/structllarp_1_1AlignedBuffer.md) & other) const |
| bool | **[operator<=](Classes/structllarp_1_1AlignedBuffer.md#function-operator<=)**(const [AlignedBuffer](Classes/structllarp_1_1AlignedBuffer.md) & other) const |
| bool | **[operator>=](Classes/structllarp_1_1AlignedBuffer.md#function-operator>=)**(const [AlignedBuffer](Classes/structllarp_1_1AlignedBuffer.md) & other) const |
| [AlignedBuffer](Classes/structllarp_1_1AlignedBuffer.md) | **[operator^](Classes/structllarp_1_1AlignedBuffer.md#function-operator^)**(const [AlignedBuffer](Classes/structllarp_1_1AlignedBuffer.md) & other) const |
| [AlignedBuffer](Classes/structllarp_1_1AlignedBuffer.md) & | **[operator^=](Classes/structllarp_1_1AlignedBuffer.md#function-operator^=)**(const [AlignedBuffer](Classes/structllarp_1_1AlignedBuffer.md) & other) |
| byte_t & | **[operator[]](Classes/structllarp_1_1AlignedBuffer.md#function-operator[])**(size_t idx) |
| const byte_t & | **[operator[]](Classes/structllarp_1_1AlignedBuffer.md#function-operator[])**(size_t idx) const |
| void | **[Fill](Classes/structllarp_1_1AlignedBuffer.md#function-fill)**(byte_t f) |
| Data & | **[as_array](Classes/structllarp_1_1AlignedBuffer.md#function-as-array)**() |
| const Data & | **[as_array](Classes/structllarp_1_1AlignedBuffer.md#function-as-array)**() const |
| byte_t * | **[data](Classes/structllarp_1_1AlignedBuffer.md#function-data)**() |
| const byte_t * | **[data](Classes/structllarp_1_1AlignedBuffer.md#function-data)**() const |
| bool | **[IsZero](Classes/structllarp_1_1AlignedBuffer.md#function-iszero)**() const |
| void | **[Zero](Classes/structllarp_1_1AlignedBuffer.md#function-zero)**() |
| virtual void | **[Randomize](Classes/structllarp_1_1AlignedBuffer.md#function-randomize)**() |
| Data::iterator | **[begin](Classes/structllarp_1_1AlignedBuffer.md#function-begin)**() |
| Data::iterator | **[end](Classes/structllarp_1_1AlignedBuffer.md#function-end)**() |
| Data::const_iterator | **[begin](Classes/structllarp_1_1AlignedBuffer.md#function-begin)**() const |
| Data::const_iterator | **[end](Classes/structllarp_1_1AlignedBuffer.md#function-end)**() const |
| bool | **[FromBytestring](Classes/structllarp_1_1AlignedBuffer.md#function-frombytestring)**([llarp_buffer_t](Classes/structllarp__buffer__t.md) * buf) |
| bool | **[BEncode](Classes/structllarp_1_1AlignedBuffer.md#function-bencode)**([llarp_buffer_t](Classes/structllarp__buffer__t.md) * buf) const |
| bool | **[BDecode](Classes/structllarp_1_1AlignedBuffer.md#function-bdecode)**([llarp_buffer_t](Classes/structllarp__buffer__t.md) * buf) |
| std::string_view | **[ToView](Classes/structllarp_1_1AlignedBuffer.md#function-toview)**() const |
| std::string | **[ToHex](Classes/structllarp_1_1AlignedBuffer.md#function-tohex)**() const |
| std::string | **[ShortHex](Classes/structllarp_1_1AlignedBuffer.md#function-shorthex)**() const |
| bool | **[FromHex](Classes/structllarp_1_1AlignedBuffer.md#function-fromhex)**(std::string_view str) |
| constexpr size_t | **[size](Classes/structllarp_1_1AlignedBuffer.md#function-size)**() |

## Public Attributes

|                | Name           |
| -------------- | -------------- |
| constexpr size_t | **[SIZE](Classes/structllarp_1_1AlignedBuffer.md#variable-size)**  |

## Detailed Description

```cpp
template <size_t sz>
struct llarp::AlignedBuffer;
```

aligned buffer that is sz bytes long and aligns to the nearest Alignment 
## Public Types Documentation

### using Data

```cpp
using llarp::AlignedBuffer< sz >::Data =  std::array<byte_t, SIZE>;
```


## Public Functions Documentation

### function ~AlignedBuffer

```cpp
virtual ~AlignedBuffer() =default
```


### function AlignedBuffer

```cpp
inline AlignedBuffer()
```


### function AlignedBuffer

```cpp
inline explicit AlignedBuffer(
    const byte_t * data
)
```


### function AlignedBuffer

```cpp
inline explicit AlignedBuffer(
    const Data & buf
)
```


### function operator=

```cpp
inline AlignedBuffer & operator=(
    const byte_t * data
)
```


### function operator~

```cpp
inline AlignedBuffer< sz > operator~() const
```

bitwise NOT 

### function operator==

```cpp
inline bool operator==(
    const AlignedBuffer & other
) const
```


### function operator!=

```cpp
inline bool operator!=(
    const AlignedBuffer & other
) const
```


### function operator<

```cpp
inline bool operator<(
    const AlignedBuffer & other
) const
```


### function operator>

```cpp
inline bool operator>(
    const AlignedBuffer & other
) const
```


### function operator<=

```cpp
inline bool operator<=(
    const AlignedBuffer & other
) const
```


### function operator>=

```cpp
inline bool operator>=(
    const AlignedBuffer & other
) const
```


### function operator^

```cpp
inline AlignedBuffer operator^(
    const AlignedBuffer & other
) const
```


### function operator^=

```cpp
inline AlignedBuffer & operator^=(
    const AlignedBuffer & other
)
```


### function operator[]

```cpp
inline byte_t & operator[](
    size_t idx
)
```


### function operator[]

```cpp
inline const byte_t & operator[](
    size_t idx
) const
```


### function Fill

```cpp
inline void Fill(
    byte_t f
)
```


### function as_array

```cpp
inline Data & as_array()
```


### function as_array

```cpp
inline const Data & as_array() const
```


### function data

```cpp
inline byte_t * data()
```


### function data

```cpp
inline const byte_t * data() const
```


### function IsZero

```cpp
inline bool IsZero() const
```


### function Zero

```cpp
inline void Zero()
```


### function Randomize

```cpp
inline virtual void Randomize()
```


**Reimplemented by**: [llarp::service::ConvoTag::Randomize](Classes/structllarp_1_1service_1_1ConvoTag.md#function-randomize)


### function begin

```cpp
inline Data::iterator begin()
```


### function end

```cpp
inline Data::iterator end()
```


### function begin

```cpp
inline Data::const_iterator begin() const
```


### function end

```cpp
inline Data::const_iterator end() const
```


### function FromBytestring

```cpp
inline bool FromBytestring(
    llarp_buffer_t * buf
)
```


### function BEncode

```cpp
inline bool BEncode(
    llarp_buffer_t * buf
) const
```


### function BDecode

```cpp
inline bool BDecode(
    llarp_buffer_t * buf
)
```


### function ToView

```cpp
inline std::string_view ToView() const
```


### function ToHex

```cpp
inline std::string ToHex() const
```


### function ShortHex

```cpp
inline std::string ShortHex() const
```


### function FromHex

```cpp
inline bool FromHex(
    std::string_view str
)
```


### function size

```cpp
static inline constexpr size_t size()
```


## Public Attributes Documentation

### variable SIZE

```cpp
static constexpr size_t SIZE = sz;
```


-------------------------------

Updated on 2023-01-27 at 23:09:26 +0000