CeresEngine 0.2.0
A game development framework
Loading...
Searching...
No Matches
SmallVector.hpp
Go to the documentation of this file.
1//
2// CeresEngine - A game development framework
3//
4// Created by Rogiel Sulzbach.
5// Copyright (c) 2018-2022 Rogiel Sulzbach. All rights reserved.
6//
7
8#pragma once
9
12
13#include <sfl/small_vector.hpp>
14
15namespace CeresEngine {
16
30 template<typename T, std::size_t N, typename RawAllocator = DefaultAllocator>
31 using SmallVector = sfl::small_vector<T, N, ScopedAllocatorAdaptor<StdAllocator<T, RawAllocator>>>;
32
33} // namespace CeresEngine
34
35template<typename T, size_t StaticCapacity, class Alloc> struct std::hash<CeresEngine::SmallVector<T, StaticCapacity, Alloc>> {
37 constexpr size_t operator()(const Type& obj) const {
38 size_t seed = CeresEngine::hash(obj.size());
39 for(const T& value : obj) {
40 CeresEngine::combine(seed, value);
41 }
42 return seed;
43 }
44};
Definition Application.hpp:19
constexpr void combine(std::size_t &seed, const T &v)
Generates a new hash for the provided type using the default standard hasher and combines it with a p...
Definition Hash.hpp:32
sfl::small_vector< T, N, ScopedAllocatorAdaptor< StdAllocator< T, RawAllocator > > > SmallVector
SmallVector is a sequence container similar to Vector.
Definition SmallVector.hpp:31
constexpr size_t hash(const T &v)
Generates a hash for the provided type.
Definition Hash.hpp:25