Lumiera  0.pre.03
»edit your freedom«
tuple-diagnostics.hpp
Go to the documentation of this file.
1 /*
2  TUPLE-DIAGNOSTICS - helper for diagnostics of type tuples
3 
4  Copyright (C)
5  2009, Hermann Vosseler <Ichthyostega@web.de>
6 
7   **Lumiera** is free software; you can redistribute it and/or modify it
8   under the terms of the GNU General Public License as published by the
9   Free Software Foundation; either version 2 of the License, or (at your
10   option) any later version. See the file COPYING for further details.
11 
12 * *****************************************************************/
13 
14 
29 #ifndef META_TUPLE_DIAGNOSTICS_H
30 #define META_TUPLE_DIAGNOSTICS_H
31 
32 
35 #include "lib/format-string.hpp"
36 #include "lib/format-obj.hpp"
37 
38 #include <string>
39 
40 using std::string;
41 
42 
43 namespace util {
44 
45  template<int i>
46  struct StringConv<lib::meta::Num<i>>
47  {
48  static std::string
49  invoke (lib::meta::Num<i> num) noexcept
50  {
51  static util::_Fmt constElm("(%i)");
52  static util::_Fmt changedElm("{%i}");
53 
54  return string( (num.o_==i? constElm:changedElm) % int(num.o_));
55  }
56  };
57 
58 }
59 
60 namespace lib {
61 namespace meta {
62 namespace test {
63 
64 
65 
66  /* ===== printing Tuple types and contents ===== */
67 
68 
69  template<typename TUP>
70  inline enable_if<is_Tuple<TUP>,
71  string >
72  showType ()
73  {
74  using TypeList = typename RebindTupleTypes<TUP>::List;
75  using DumpPrinter = InstantiateChained<TypeList, Printer, NullP>;
76 
77  return "TUPLE"
78  + DumpPrinter::print();
79  }
80 
81  // see the macros DISPLAY and DUMPVAL defined in typelist-diagnostics.hpp
82 
83 
84 
85 
86 }}} // namespace lib::meta::test
87 #endif
Definition: run.hpp:40
Front-end for printf-style string template interpolation.
A front-end for using printf-style formatting.
Implementation namespace for support and library code.
Metaprogramming with tuples-of-types and the std::tuple record.
Simple functions to represent objects, for debugging and diagnostics.
Support for writing metaprogramming unit-tests dealing with typelists and flags.
failsafe invocation of custom string conversion.
Definition: meta/util.hpp:390
constant-wrapper type for debugging purposes, usable for generating lists of distinguishable types ...