summaryrefslogtreecommitdiff
path: root/base
diff options
context:
space:
mode:
authorHunter Knepshield <hknepshield@google.com>2020-02-20 13:17:42 -0800
committerHunter Knepshield <hknepshield@google.com>2020-02-20 13:17:42 -0800
commit5529b82c09f1fceb32b1a81d985b7f1cdfd5d928 (patch)
tree4462dbeede906a76a1c9c60c48b5917bc4169211 /base
parent750364bd76be3714903f267e7a61de8fb6e69a8c (diff)
downloadlibhidl-5529b82c09f1fceb32b1a81d985b7f1cdfd5d928.tar.gz
Add container-like value_type alias to hidl_enum_range.
This allows instantiations like ::testing::ValuesIn(hidl_enum_range<Foo>()). Test: make Test: atest VtsHalDumpstateV1_1TargetTest Change-Id: I1313a67c152ff830ca5ab9a7285b6e9fcb539444
Diffstat (limited to 'base')
-rw-r--r--base/include/hidl/HidlSupport.h3
1 files changed, 3 insertions, 0 deletions
diff --git a/base/include/hidl/HidlSupport.h b/base/include/hidl/HidlSupport.h
index 1b91c26..9343f0f 100644
--- a/base/include/hidl/HidlSupport.h
+++ b/base/include/hidl/HidlSupport.h
@@ -1044,6 +1044,9 @@ constexpr hidl_invalid_type<T> hidl_enum_values;
*/
template <typename T, typename = std::enable_if_t<std::is_enum<T>::value>>
struct hidl_enum_range {
+ // Container-like associated type.
+ using value_type = T;
+
constexpr auto begin() const { return std::begin(details::hidl_enum_values<T>); }
constexpr auto cbegin() const { return begin(); }
constexpr auto rbegin() const { return std::rbegin(details::hidl_enum_values<T>); }