proxygen
TypeListTest.cpp File Reference

Go to the source code of this file.

Classes

struct  Cons< Car, Cdr >
 

Typedefs

template<class T >
using AddPointer = T *
 
using Nil = Empty
 

Functions

 TEST (TypeList, Basic)
 
 TEST (TypeList, Defer)
 
 TEST (TypeList, Transform)
 
 TEST (TypeList, Fold)
 
 TEST (TypeList, Unique)
 
 TEST (TypeList, PushFront)
 
 TEST (TypeList, PushBack)
 
 TEST (TypeList, Join)
 

Typedef Documentation

template<class T >
using AddPointer = T*

Definition at line 40 of file TypeListTest.cpp.

using Nil = Empty

Definition at line 59 of file TypeListTest.cpp.

Function Documentation

TEST ( TypeList  ,
Basic   
)

Definition at line 33 of file TypeListTest.cpp.

33  {
34  static_assert(TypeList<>::size() == 0, "");
35  static_assert(TypeList<int>::size() == 1, "");
36  static_assert(TypeList<int, short, float>::size() == 3, "");
37 }
TEST ( TypeList  ,
Defer   
)

Definition at line 42 of file TypeListTest.cpp.

References folly::value().

42  {
43  static_assert(
44  std::is_same<MetaApply<MetaDefer<AddPointer, int>>, int*>::value, "");
45  static_assert(!IsApplicable<MetaDefer<AddPointer, int, short>>::value, "");
46  static_assert(!IsApplicable<MetaDefer<AddPointer, int&>>::value, "");
47 }
typename Fn::template apply< Ts... > MetaApply
Definition: TypeList.h:90
static const char *const value
Definition: Conv.cpp:50
TEST ( TypeList  ,
Transform   
)

Definition at line 49 of file TypeListTest.cpp.

References folly::value().

49  {
50  using Fn = MetaQuote<AddPointer>;
51  using T1 = TypeTransform<TypeList<>, Fn>;
52  static_assert(std::is_same<T1, TypeList<>>::value, "");
53  using T2 = TypeTransform<TypeList<int>, Fn>;
54  static_assert(std::is_same<T2, TypeList<int*>>::value, "");
56  static_assert(std::is_same<T3, TypeList<int*, short*, void*>>::value, "");
57 }
MetaApply< List, impl::TypeTransform_< Fn >> TypeTransform
Definition: TypeList.h:327
static const char *const value
Definition: Conv.cpp:50
TEST ( TypeList  ,
Fold   
)

Definition at line 63 of file TypeListTest.cpp.

References folly::E1, folly::E2, and value.

63  {
64  using Fn = MetaQuote<Cons>;
67  static_assert(std::is_same<T1, E1>::value, "");
68 
70  using E2 = Cons<
71  int,
73  static_assert(std::is_same<T2, E2>::value, "");
74 
77  static_assert(std::is_same<T3, E3>::value, "");
78 
79  using T4 = TypeReverseFold<
81  Nil,
82  MetaFlip<Fn>>;
83  using E4 = Cons<
84  void*,
86  static_assert(std::is_same<T4, E4>::value, "");
87 }
MetaApply< MetaApply< List, impl::FoldR_< Fn >>, State > TypeFold
Definition: TypeList.h:380
Empty Nil
MetaApply< MetaApply< List, impl::FoldL_< Fn >>, State > TypeReverseFold
Definition: TypeList.h:419
static const char *const value
Definition: Conv.cpp:50
TEST ( TypeList  ,
Unique   
)

Definition at line 89 of file TypeListTest.cpp.

References folly::value().

89  {
91  static_assert(std::is_same<T1, TypeList<int, short>>::value, "");
92 
94  static_assert(std::is_same<T2, TypeList<short, int>>::value, "");
95 }
static const char *const value
Definition: Conv.cpp:50
TypeReverseFold< List, TypeList<>, MetaFlip< impl::Unique_ >> TypeReverseUnique
Definition: TypeList.h:488
TypeFold< List, TypeList<>, impl::Unique_ > TypeUnique
Definition: TypeList.h:475
TEST ( TypeList  ,
PushFront   
)

Definition at line 97 of file TypeListTest.cpp.

References folly::value().

97  {
98  using T1 = TypePushFront<TypeList<>, int, short>;
99  static_assert(std::is_same<T1, TypeList<int, short>>::value, "");
100 
102  static_assert(
104  "");
105 }
MetaApply< List, MetaBindFront< MetaQuote< TypeList >, Ts... >> TypePushFront
Definition: TypeList.h:301
static const char *const value
Definition: Conv.cpp:50
TEST ( TypeList  ,
PushBack   
)

Definition at line 107 of file TypeListTest.cpp.

References folly::value().

107  {
108  using T1 = TypePushBack<TypeList<>, int, short>;
109  static_assert(std::is_same<T1, TypeList<int, short>>::value, "");
110 
112  static_assert(
114  "");
115 }
MetaApply< List, MetaBindBack< MetaQuote< TypeList >, Ts... >> TypePushBack
Definition: TypeList.h:290
static const char *const value
Definition: Conv.cpp:50
TEST ( TypeList  ,
Join   
)

Definition at line 117 of file TypeListTest.cpp.

References folly::value().

117  {
118  using T1 = TypeJoin<
120  static_assert(
121  std::is_same<T1, TypeList<int, short, float, void*>>::value, "");
122 }
static const char *const value
Definition: Conv.cpp:50
MetaApply< TypeFold< List, MetaQuote< TypeList >, impl::Join_ >> TypeJoin
Definition: TypeList.h:538