LeechCraft  0.6.70-15082-g543737046d
Modular cross-platform feature rich live environment.
typegettertest.cpp
Go to the documentation of this file.
1 /**********************************************************************
2  * LeechCraft - modular cross-platform feature rich internet client.
3  * Copyright (C) 2006-2014 Georg Rudoy
4  *
5  * Distributed under the Boost Software License, Version 1.0.
6  * (See accompanying file LICENSE or copy at https://www.boost.org/LICENSE_1_0.txt)
7  **********************************************************************/
8 
9 #include "typegettertest.h"
10 #include <type_traits>
11 #include <QtTest>
12 #include <typegetter.h>
13 
14 QTEST_MAIN (LC::Util::TypeGetterTest)
15 
16 namespace LC
17 {
18 namespace Util
19 {
20  namespace
21  {
22  template<typename T>
23  void PrintType ()
24  {
25  qDebug () << Q_FUNC_INFO;
26  }
27  }
28 
29  void TypeGetterTest::testArgType ()
30  {
31  const auto f = [] (int, const double) {};
32  static_assert (std::is_same_v<ArgType_t<decltype (f), 0>, int>);
33  static_assert (std::is_same_v<ArgType_t<decltype (f), 1>, double>);
34  }
35 
36  void TypeGetterTest::testArgTypeRef ()
37  {
38  const auto f = [] (int&, const double&) {};
39  static_assert (std::is_same_v<ArgType_t<decltype (f), 0>, int&>);
40  static_assert (std::is_same_v<ArgType_t<decltype (f), 1>, const double&>);
41  }
42 
43  void TypeGetterTest::testArgTypeRvalueRef ()
44  {
45  const auto f = [] (int&&, const double&&) {};
46  static_assert (std::is_same_v<ArgType_t<decltype (f), 0>, int&&>);
47  static_assert (std::is_same_v<ArgType_t<decltype (f), 1>, const double&&>);
48  }
49 
50  void TypeGetterTest::testRetType ()
51  {
52  const auto f = [] (int val, const double) { return val; };
53  static_assert (std::is_same_v<RetType_t<decltype (f)>, int>);
54  }
55 
56  void TypeGetterTest::testRetTypeVoid ()
57  {
58  const auto f = [] {};
59  static_assert (std::is_same_v<RetType_t<decltype (f)>, void>);
60  }
61 
62  void TypeGetterTest::testRetTypeRef ()
63  {
64  int x;
65  const auto f = [&x] (int, const double) -> int& { return x; };
66  static_assert (std::is_same_v<RetType_t<decltype (f)>, int&>);
67  }
68 
69  void TypeGetterTest::testRetTypeConstRef ()
70  {
71  int x;
72  const auto f = [&x] (int, const double) -> const int& { return x; };
73  static_assert (std::is_same_v<RetType_t<decltype (f)>, const int&>);
74  }
75 }
76 }
typegettertest.h
LC::Util::ArgType_t
std::tuple_element_t< Idx+1, decltype(detail::TypeGetter(*static_cast< F * >(nullptr)))> ArgType_t
Definition: typegetter.h:40
typegetter.h
LC
Definition: constants.h:14
LC::Util::TypeGetterTest
Definition: typegettertest.h:29
LC::Util::oral::sph::f
constexpr detail::ExprTree< detail::ExprType::LeafStaticPlaceholder, detail::MemberPtrs< Ptr > > f
Definition: oral.h:952
LC::Util::RetType_t
std::tuple_element_t< 0, decltype(detail::TypeGetter(*static_cast< F * >(nullptr)))> RetType_t
Definition: typegetter.h:43