summaryrefslogtreecommitdiff
path: root/include/o3tl
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2018-09-19 08:55:09 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2018-09-19 10:33:28 +0200
commit0bc059f2a893d812e29d6a72d4f988428b5ea346 (patch)
tree62ff7c996c784b563eb840e18002da4ce985cd0d /include/o3tl
parentae3150b1e1863e854224c2e41c7e50991f945dad (diff)
implement find(T*) for o3tl::sorted_vector when it contains unique_ptr<T>
and add some unit tests Change-Id: I9a01c9fa2fbbf3a553663a980ee6e958f9819645 Reviewed-on: https://gerrit.libreoffice.org/60737 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'include/o3tl')
-rw-r--r--include/o3tl/sorted_vector.hxx12
1 files changed, 12 insertions, 0 deletions
diff --git a/include/o3tl/sorted_vector.hxx b/include/o3tl/sorted_vector.hxx
index 254d627604df..7c95a1ace24e 100644
--- a/include/o3tl/sorted_vector.hxx
+++ b/include/o3tl/sorted_vector.hxx
@@ -224,6 +224,7 @@ class sorted_vector<Value,Compare,Find,false> : public sorted_vector<Value, Comp
{
public:
using sorted_vector<Value, Compare, Find, true>::sorted_vector;
+ typedef sorted_vector<Value, Compare, Find, true> super_sorted_vector;
sorted_vector(sorted_vector const&) = delete;
sorted_vector& operator=(sorted_vector const&) = delete;
@@ -231,6 +232,17 @@ public:
sorted_vector() = default;
sorted_vector(sorted_vector&&) = default;
sorted_vector& operator=(sorted_vector&&) = default;
+
+ /**
+ * implement find for sorted_vectors containing std::unique_ptr
+ */
+ typename super_sorted_vector::const_iterator find( typename Value::element_type const * x ) const
+ {
+ Value tmp(const_cast<typename Value::element_type*>(x));
+ auto ret = super_sorted_vector::find(tmp);
+ tmp.release();
+ return ret;
+ }
};