Fix compiler warning
This commit is contained in:
parent
9c15076350
commit
b83be2c32d
19
implementations/caching/cache/QueueMap.h
vendored
19
implementations/caching/cache/QueueMap.h
vendored
@ -19,7 +19,7 @@ namespace caching {
|
|||||||
|
|
||||||
// A class that is a queue and a map at the same time. We could also see it as an addressable queue.
|
// A class that is a queue and a map at the same time. We could also see it as an addressable queue.
|
||||||
template<class Key, class Value>
|
template<class Key, class Value>
|
||||||
class QueueMap {
|
class QueueMap final {
|
||||||
public:
|
public:
|
||||||
QueueMap(): _entries(), _sentinel(&_sentinel, &_sentinel) {
|
QueueMap(): _entries(), _sentinel(&_sentinel, &_sentinel) {
|
||||||
}
|
}
|
||||||
@ -77,27 +77,30 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
class Entry {
|
class Entry final {
|
||||||
public:
|
public:
|
||||||
Entry(Entry *prev_, Entry *next_): prev(prev_), next(next_), key(nullptr), _value() {
|
Entry(Entry *prev_, Entry *next_): prev(prev_), next(next_), key(nullptr), __value() {
|
||||||
}
|
}
|
||||||
void init(const Key *key_, Value value_) {
|
void init(const Key *key_, Value value_) {
|
||||||
key = key_;
|
key = key_;
|
||||||
new(_value) Value(std::move(value_));
|
new(__value) Value(std::move(value_));
|
||||||
}
|
}
|
||||||
Value release() {
|
Value release() {
|
||||||
Value value = std::move(*reinterpret_cast<Value*>(_value));
|
Value value = std::move(*_value());
|
||||||
reinterpret_cast<Value*>(_value)->~Value();
|
_value()->~Value();
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
const Value &value() {
|
const Value &value() {
|
||||||
return *reinterpret_cast<Value*>(_value);
|
return *_value();
|
||||||
}
|
}
|
||||||
Entry *prev;
|
Entry *prev;
|
||||||
Entry *next;
|
Entry *next;
|
||||||
const Key *key;
|
const Key *key;
|
||||||
private:
|
private:
|
||||||
alignas(Value) char _value[sizeof(Value)];
|
Value *_value() {
|
||||||
|
return reinterpret_cast<Value*>(__value);
|
||||||
|
}
|
||||||
|
alignas(Value) char __value[sizeof(Value)];
|
||||||
DISALLOW_COPY_AND_ASSIGN(Entry);
|
DISALLOW_COPY_AND_ASSIGN(Entry);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user