summaryrefslogtreecommitdiffstats
path: root/src/gallium/state_trackers/clover/util
diff options
context:
space:
mode:
Diffstat (limited to 'src/gallium/state_trackers/clover/util')
-rw-r--r--src/gallium/state_trackers/clover/util/algorithm.hpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/gallium/state_trackers/clover/util/algorithm.hpp b/src/gallium/state_trackers/clover/util/algorithm.hpp
index 4eb90cffa9f..1658458ee18 100644
--- a/src/gallium/state_trackers/clover/util/algorithm.hpp
+++ b/src/gallium/state_trackers/clover/util/algorithm.hpp
@@ -56,6 +56,18 @@ namespace clover {
}
///
+ /// Return the only element in a range.
+ ///
+ template<typename R>
+ detail::preferred_reference_type<R>
+ unique(R &&r) {
+ if (r.size() != 1)
+ throw std::out_of_range("");
+
+ return r.front();
+ }
+
+ ///
/// Combine a variable number of ranges element-wise in a single
/// range of tuples.
///