New issue
Advanced search Search tips

Issue 665735 link

Starred by 2 users

Issue metadata

Status: Verified
Owner: ----
Closed: Dec 2016
Cc:
EstimatedDays: ----
NextAction: ----
OS: ----
Pri: 3
Type: Bug



Sign in to add a comment

Allow specification of comparator in MRUCache

Project Member Reported by eranm@chromium.org, Nov 16 2016

Issue description

The MRUCache class (https://cs.chromium.org/chromium/src/base/containers/mru_cache.h?cl=GROK&gsn=CERT_POLICY_COMPLIES_VIA_SCTS&q=mrucache&sq=package:chromium&l=213) takes as template parameters the KeyType and PayloadType.

It specifies the default comparator, std::less<KeyType> to its superclass, MRUCacheBase.

That means user-defined types cannot be used in the MRUCache unless std::less is specialized for them in the global namespace (as far as I understand).

This is preventing me from using directly the object I want in the MRUCache (SHA256HashValue), forcing me to convert it to a string.
 

Comment 1 by ajha@chromium.org, Nov 18 2016

Labels: M-56
Project Member

Comment 2 by bugdroid1@chromium.org, Nov 29 2016

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/b36da9dffc6fed50a8d72d1818d5a574e6502940

commit b36da9dffc6fed50a8d72d1818d5a574e6502940
Author: rsleevi <rsleevi@chromium.org>
Date: Tue Nov 29 02:56:31 2016

Allow custom comparators for the MRUCache

//base's MRUCache allowed specifying key and value types, like
an underlying std::map<>, but the default base::MRUCache explicitly
specialized the comparator as std::less<>. Rather than require the
caller to overload std::less<> or operator<, allow the comparator
to be specified as a templated argument.

BUG= 665735 

Review-Url: https://codereview.chromium.org/2532313002
Cr-Commit-Position: refs/heads/master@{#434850}

[modify] https://crrev.com/b36da9dffc6fed50a8d72d1818d5a574e6502940/base/containers/mru_cache.h

Status: Verified (was: Available)

Sign in to add a comment