16#ifndef WPIUTIL_WPI_STRINGMAPENTRY_H
17#define WPIUTIL_WPI_STRINGMAPENTRY_H
41 template <
typename AllocatorTy>
47template <
typename AllocatorTy>
50 AllocatorTy &Allocator) {
51 size_t KeyLength = Key.size();
55 size_t AllocSize = EntrySize + KeyLength + 1;
56 void *Allocation = Allocator.Allocate(AllocSize, EntryAlign);
57 assert(Allocation &&
"Unhandled out-of-memory");
60 char *Buffer =
reinterpret_cast<char *
>(Allocation) + EntrySize;
62 ::memcpy(Buffer, Key.data(), KeyLength);
63 Buffer[KeyLength] = 0;
72template <
typename ValueTy>
79 template <
typename... InitTy>
82 second(
std::forward<InitTy>(initVals)...) {}
97 std::nullopt_t
getValue()
const {
return std::nullopt; }
103template <
typename ValueTy>
116 return reinterpret_cast<const char *
>(
this + 1);
125 template <
typename AllocatorTy,
typename... InitTy>
127 InitTy &&... initVals) {
142 template <
typename AllocatorTy>
void Destroy(AllocatorTy &allocator) {
146 allocator.Deallocate(
static_cast<void *
>(
this), AllocSize,
This file defines counterparts of C library allocation functions defined in the namespace 'std'.
StringMapEntryBase - Shared base class of StringMapEntry instances.
Definition: StringMapEntry.h:29
static void * allocateWithKey(size_t EntrySize, size_t EntryAlign, std::string_view Key, AllocatorTy &Allocator)
Helper to tail-allocate Key.
Definition: StringMapEntry.h:48
StringMapEntryBase(size_t keyLength)
Definition: StringMapEntry.h:33
size_t getKeyLength() const
Definition: StringMapEntry.h:35
StringMapEntry - This is used to represent one value that is inserted into a StringMap.
Definition: StringMapEntry.h:104
static StringMapEntry & GetStringMapEntryFromKeyData(const char *keyData)
GetStringMapEntryFromKeyData - Given key data that is known to be embedded into a StringMapEntry,...
Definition: StringMapEntry.h:135
static StringMapEntry * Create(std::string_view key, AllocatorTy &allocator, InitTy &&... initVals)
Create a StringMapEntry for the specified key construct the value using InitiVals.
Definition: StringMapEntry.h:126
std::string_view first() const
Definition: StringMapEntry.h:119
const char * getKeyData() const
getKeyData - Return the start of the string data that is the key for this value.
Definition: StringMapEntry.h:115
std::string_view getKey() const
Definition: StringMapEntry.h:108
void Destroy(AllocatorTy &allocator)
Destroy - Destroy this StringMapEntry, releasing memory back to the specified allocator.
Definition: StringMapEntry.h:142
std::nullopt_t getValue() const
Definition: StringMapEntry.h:97
StringMapEntryStorage(size_t keyLength, std::nullopt_t=std::nullopt)
Definition: StringMapEntry.h:93
StringMapEntryStorage(StringMapEntryStorage &entry)=delete
StringMapEntryStorage - Holds the value in a StringMapEntry.
Definition: StringMapEntry.h:73
StringMapEntryStorage(size_t keyLength, InitTy &&... initVals)
Definition: StringMapEntry.h:80
StringMapEntryStorage(size_t keyLength)
Definition: StringMapEntry.h:77
const ValueTy & getValue() const
Definition: StringMapEntry.h:85
void setValue(const ValueTy &V)
Definition: StringMapEntry.h:88
ValueTy & getValue()
Definition: StringMapEntry.h:86
StringMapEntryStorage(StringMapEntryStorage &e)=delete
ValueTy second
Definition: StringMapEntry.h:75
basic_string_view< char > string_view
Definition: core.h:520
Definition: BFloat16.h:88
static constexpr const charge::coulomb_t e(1.6021766208e-19)
elementary charge.
Definition: AprilTagFieldLayout.h:18