Skip to content

Commit 9817ece

Browse files
committed
GetPointerToSelf instead of self pointer member
1 parent d3fdf10 commit 9817ece

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

libraries/multi_index_lru/include/userver/multi_index_lru/lru_boost_list_container.h

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#include <boost/intrusive/list.hpp>
55
#include <boost/intrusive/list_hook.hpp>
66
#include <boost/multi_index/hashed_index.hpp>
7+
#include <boost/multi_index/mem_fun.hpp>
78

89
#include <list>
910
#include <functional>
@@ -20,15 +21,11 @@ struct ValueWithHook
2021
{
2122
Value value;
2223
mutable boost::intrusive::list_member_hook<> list_hook;
23-
ValueWithHook *self;
24+
const ValueWithHook *GetPointerToSelf() const { return this; };
2425

25-
explicit ValueWithHook(const Value& val) : value(val) {
26-
self = this;
27-
}
26+
explicit ValueWithHook(const Value& val) : value(val) {}
2827

29-
explicit ValueWithHook(Value&& val) : value(std::move(val)) {
30-
self = this;
31-
}
28+
explicit ValueWithHook(Value&& val) : value(std::move(val)) {}
3229

3330
ValueWithHook() = delete;
3431
ValueWithHook(const ValueWithHook&) = delete;
@@ -87,7 +84,7 @@ class LRUCacheContainer {
8784
IndexSpecifierList,
8885
hashed_unique<
8986
tag<internal_ptr_tag>,
90-
member<CacheItem, CacheItem*, &CacheItem::self>
87+
const_mem_fun<CacheItem, const CacheItem*, &CacheItem::GetPointerToSelf>
9188
>
9289
>::type;
9390

0 commit comments

Comments
 (0)