Skip to main content
added 53 characters in body
Source Link
Toby Speight
  • 88.7k
  • 14
  • 104
  • 327
  • swap()
  • clear()
  • erase()
  • empty()
  • count()
  • operator[]() (for default-constructible values)
  • try_emplace()
  • merge()
  • swap()
  • clear()
  • erase()
  • empty()
  • count()
  • try_emplace()
  • merge()
  • swap()
  • clear()
  • erase()
  • empty()
  • count()
  • operator[]() (for default-constructible values)
  • try_emplace()
  • merge()
added 386 characters in body
Source Link
Toby Speight
  • 88.7k
  • 14
  • 104
  • 327

Const

There are choices to be made regarding use of const with caches. We could consider lookup either to be a const operation (meaning we'd need to use mutable specifier for the LRU list) or to be a mutating operation, as we have done here. There are good arguments for both approaches, but it would be worth having a comment that shows why this choice was preferred here.

Strange assertion

Making the collection implement a Range (perhaps in LRU order) might be worthwhile, too. For a variant using plain std::map, we might consider two Range views - one in LRU order and one in the map's preferred order.

Strange assertion

Const

There are choices to be made regarding use of const with caches. We could consider lookup either to be a const operation (meaning we'd need to use mutable specifier for the LRU list) or to be a mutating operation, as we have done here. There are good arguments for both approaches, but it would be worth having a comment that shows why this choice was preferred here.

Strange assertion

Making the collection implement a Range (perhaps in LRU order) might be worthwhile, too. For a variant using plain std::map, we might consider two Range views - one in LRU order and one in the map's preferred order.

added 174 characters in body
Source Link
Toby Speight
  • 88.7k
  • 14
  • 104
  • 327

Consider enabling transparent comparison of keys so that (for example) a user doesn't need to construct a std::string object from a string-view or C-style raw string.

Consider adding the following container functions (in no particular order):

Consider adding the following container functions (in no particular order):

Consider enabling transparent comparison of keys so that (for example) a user doesn't need to construct a std::string object from a string-view or C-style raw string.

Consider adding the following container functions (in no particular order):

added 284 characters in body
Source Link
Toby Speight
  • 88.7k
  • 14
  • 104
  • 327
Loading
Source Link
Toby Speight
  • 88.7k
  • 14
  • 104
  • 327
Loading