diff options
Diffstat (limited to 'googletest/include/gtest/internal/gtest-type-util.h.pump')
-rw-r--r-- | googletest/include/gtest/internal/gtest-type-util.h.pump | 88 |
1 files changed, 10 insertions, 78 deletions
diff --git a/googletest/include/gtest/internal/gtest-type-util.h.pump b/googletest/include/gtest/internal/gtest-type-util.h.pump index 605b78f..dcfde18 100644 --- a/googletest/include/gtest/internal/gtest-type-util.h.pump +++ b/googletest/include/gtest/internal/gtest-type-util.h.pump @@ -32,11 +32,6 @@ $var n = 50 $$ Maximum length of type lists we want to support. // Type utilities needed for implementing typed and type-parameterized // tests. This file is generated by a SCRIPT. DO NOT EDIT BY HAND! -// -// Currently we support at most $n type-parameterized tests -// in one type-parameterized test suite. -// Please contact googletestframework@googlegroups.com if you need -// more. // GOOGLETEST_CM0001 DO NOT DELETE @@ -104,6 +99,9 @@ std::string GetTypeName() { #if GTEST_HAS_TYPED_TEST || GTEST_HAS_TYPED_TEST_P +// A unique type indicating an empty node +struct None {}; + # define GTEST_TEMPLATE_ template <typename T> class // The template "selector" struct TemplateSel<Tmpl> is used to @@ -125,84 +123,18 @@ struct TemplateSel { # define GTEST_BIND_(TmplSel, T) \ TmplSel::template Bind<T>::type -// A unique struct template used as the default value for the -// arguments of class template Templates. This allows us to simulate -// variadic templates (e.g. Templates<int>, Templates<int, double>, -// and etc), which C++ doesn't support directly. -template <typename T> -struct NoneT {}; - -// The following family of struct and struct templates are used to -// represent template lists. In particular, TemplatesN<T1, T2, ..., -// TN> represents a list of N templates (T1, T2, ..., and TN). Except -// for Templates0, every struct in the family has two member types: -// Head for the selector of the first template in the list, and Tail -// for the rest of the list. - -// The empty template list. -struct Templates0 {}; - -// Template lists of length 1, 2, 3, and so on. - -template <GTEST_TEMPLATE_ T1> -struct Templates1 { - typedef TemplateSel<T1> Head; - typedef Templates0 Tail; -}; - -$range i 2..n - -$for i [[ -$range j 1..i -$range k 2..i -template <$for j, [[GTEST_TEMPLATE_ T$j]]> -struct Templates$i { - typedef TemplateSel<T1> Head; - typedef Templates$(i-1)<$for k, [[T$k]]> Tail; -}; - - -]] - -// We don't want to require the users to write TemplatesN<...> directly, -// as that would require them to count the length. Templates<...> is much -// easier to write, but generates horrible messages when there is a -// compiler error, as gcc insists on printing out each template -// argument, even if it has the default value (this means Templates<list> -// will appear as Templates<list, NoneT, NoneT, ..., NoneT> in the compiler -// errors). -// -// Our solution is to combine the best part of the two approaches: a -// user would write Templates<T1, ..., TN>, and Google Test will translate -// that to TemplatesN<T1, ..., TN> internally to make error messages -// readable. The translation is done by the 'type' member of the -// Templates template. - -$range i 1..n -template <$for i, [[GTEST_TEMPLATE_ T$i = NoneT]]> +template <GTEST_TEMPLATE_ Head_, GTEST_TEMPLATE_... Tail_> struct Templates { - typedef Templates$n<$for i, [[T$i]]> type; + using Head = TemplateSel<Head_>; + using Tail = Templates<Tail_...>; }; -template <> -struct Templates<$for i, [[NoneT]]> { - typedef Templates0 type; +template <GTEST_TEMPLATE_ Head_> +struct Templates<Head_> { + typedef TemplateSel<Head_> Head; + typedef None Tail; }; -$range i 1..n-1 -$for i [[ -$range j 1..i -$range k i+1..n -template <$for j, [[GTEST_TEMPLATE_ T$j]]> -struct Templates<$for j, [[T$j]]$for k[[, NoneT]]> { - typedef Templates$i<$for j, [[T$j]]> type; -}; - -]] - -// A unique type indicating an empty node -struct None {}; - // Tuple-like type lists template <typename Head_, typename... Tail_> struct Types { |