Sane C++ Libraries
C++ Platform Abstraction Libraries
SmallVector.h
1
// Copyright (c) Stefano Cristiano
2
// SPDX-License-Identifier: MIT
3
#pragma once
4
#include "../Containers/Vector.h"
5
6
namespace
SC
7
{
8
template
<
typename
T,
int
N>
9
struct
SmallVector;
10
}
// namespace SC
11
14
24
template
<
typename
T,
int
N>
25
struct
SC::SmallVector
:
public
Vector
<T>
26
{
27
// clang-format off
28
SmallVector
() :
Vector<T>
(inlineHeader, N *
sizeof
(T)) {}
29
SmallVector
(
const
Vector<T>
& other) :
SmallVector
() {
Vector<T>::operator=
(other); }
30
SmallVector
(
Vector<T>
&& other) :
SmallVector
() {
Vector<T>::operator=
(
move
(other)); }
31
Vector<T>
& operator=(
const
Vector<T>
& other) {
return
Vector<T>::operator=
(other); }
32
Vector<T>
& operator=(
Vector<T>
&& other) {
return
Vector<T>::operator=
(
move
(other)); }
33
34
SmallVector
(
const
SmallVector
& other) :
SmallVector
() {
Vector<T>::operator=
(other); }
35
SmallVector
(
SmallVector
&& other) :
SmallVector
() {
Vector<T>::operator=
(
move
(other)); }
36
SmallVector
& operator=(
const
SmallVector
& other) {
Vector<T>::operator=
(other);
return
*
this
; }
37
SmallVector
& operator=(
SmallVector
&& other) {
Vector<T>::operator=
(
move
(other));
return
*
this
; }
38
// clang-format on
39
40
private
:
41
SegmentHeader
inlineHeader;
42
char
inlineBuffer[N *
sizeof
(T)];
43
};
SC::move
constexpr T && move(T &value)
Converts an lvalue to an rvalue reference.
Definition:
Compiler.h:269
SC::SegmentHeader
Definition:
Segment.h:11
SC::SmallVector
A Vector that can hold up to N elements inline and > N on heap.
Definition:
SmallVector.h:26
SC::Vector
A contiguous sequence of heap allocated elements.
Definition:
Vector.h:257
Libraries
Containers
SmallVector.h
Generated by
1.9.2