summaryrefslogtreecommitdiffstats
path: root/googletest/include/gtest/internal/gtest-param-util.h
diff options
context:
space:
mode:
Diffstat (limited to 'googletest/include/gtest/internal/gtest-param-util.h')
-rw-r--r--googletest/include/gtest/internal/gtest-param-util.h46
1 files changed, 9 insertions, 37 deletions
diff --git a/googletest/include/gtest/internal/gtest-param-util.h b/googletest/include/gtest/internal/gtest-param-util.h
index 2dea63c..d5d4da9 100644
--- a/googletest/include/gtest/internal/gtest-param-util.h
+++ b/googletest/include/gtest/internal/gtest-param-util.h
@@ -74,27 +74,6 @@ namespace internal {
// INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE.
// Utility Functions
-// Block of code creating for_each_in_tuple
-template <int... Is>
-struct sequence {};
-
-template <int N, int... Is>
-struct generate_sequence : generate_sequence<N - 1, N - 1, Is...> {};
-
-template <int... Is>
-struct generate_sequence<0, Is...> : sequence<Is...> {};
-
-template <typename T, typename F, int... Is>
-void ForEachInTupleImpl(T&& t, F f_gtest, sequence<Is...>) {
- int l[] = {(f_gtest(std::get<Is>(t)), 0)...};
- (void)l; // silence "unused variable warning"
-}
-template <typename... T, typename F>
-void ForEachInTuple(const std::tuple<T...>& t, F f_gtest) {
- internal::ForEachInTupleImpl(t, f_gtest,
- internal::generate_sequence<sizeof...(T)>());
-}
-
// Outputs a message explaining invalid registration of different
// fixture class for the same test case. This may happen when
// TEST_P macro is used to define two tests with the same name
@@ -747,30 +726,23 @@ internal::ParamGenerator<typename Container::value_type> ValuesIn(
namespace internal {
// Used in the Values() function to provide polymorphic capabilities.
-template <typename T>
-struct PushBack {
- template <typename U>
- void operator()(const U& u) {
- v_.push_back(static_cast<T>(u));
- }
- std::vector<T>& v_;
-};
-
template <typename... Ts>
class ValueArray {
public:
ValueArray(Ts... v) : v_{std::move(v)...} {}
- template <typename Tn>
- operator ParamGenerator<Tn>() const {
- std::vector<Tn> vc_accumulate;
- PushBack<Tn> fnc{vc_accumulate};
- ForEachInTuple(v_, fnc);
- return ValuesIn(std::move(vc_accumulate));
+ template <typename T>
+ operator ParamGenerator<T>() const { // NOLINT
+ return ValuesIn(MakeVector<T>(MakeIndexSequence<sizeof...(Ts)>()));
}
private:
- std::tuple<Ts...> v_;
+ template <typename T, size_t... I>
+ std::vector<T> MakeVector(IndexSequence<I...>) const {
+ return std::vector<T>{static_cast<T>(v_.template Get<I>())...};
+ }
+
+ FlatTuple<Ts...> v_;
};
} // namespace internal