Clarify comment

This commit is contained in:
Guillaume Munch 2017-02-22 16:56:43 +01:00
parent b01dd12c72
commit 8353a53cc3

View File

@ -51,15 +51,17 @@ public:
{ {
return Q::insert(key, new Val(std::move(object)), cost); return Q::insert(key, new Val(std::move(object)), cost);
} }
// Returns the default value (e.g. null pointer) before using the result. If // Returns the default value (e.g. null pointer) if not found in the
// this is not convenient for your type, check if it exists beforehand with // cache. If this is not convenient for your class Val, check if it exists
// Cache::contains. // beforehand with Cache::contains.
Val object(Key const & key) const Val object(Key const & key) const
{ {
if (Val * obj = Q::object(key)) if (Val * obj = Q::object(key))
return *obj; return *obj;
return Val(); return Val();
} }
/// Synonymous for object, same remark as above.
Val operator[](Key const & key) const { return object(key); }
/// Everything from QCache except QCache::take. /// Everything from QCache except QCache::take.
using Q::clear; using Q::clear;
using Q::contains; using Q::contains;
@ -71,7 +73,6 @@ public:
int max_cost() const { return Q::maxCost(); } int max_cost() const { return Q::maxCost(); }
void set_max_cost(int cost) { Q::setMaxCost(cost); } void set_max_cost(int cost) { Q::setMaxCost(cost); }
int total_cost() const { return Q::totalCost(); } int total_cost() const { return Q::totalCost(); }
Val operator[](Key const & key) const { return object(key); }
}; };
} // namespace lyx } // namespace lyx