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) Lumiera.org
5  2009, Hermann Vosseler <Ichthyostega@web.de>
6 
7  This program is free software; you can redistribute it and/or
8  modify it under the terms of the GNU General Public License as
9  published by the Free Software Foundation; either version 2 of
10  the License, or (at your option) any later version.
11 
12  This program is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  GNU General Public License for more details.
16 
17  You should have received a copy of the GNU General Public License
18  along with this program; if not, write to the Free Software
19  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 
21 * *****************************************************/
22 
23 
38 #ifndef META_TUPLE_DIAGNOSTICS_H
39 #define META_TUPLE_DIAGNOSTICS_H
40 
41 
44 #include "lib/format-string.hpp"
45 #include "lib/format-obj.hpp"
46 
47 #include <string>
48 
49 using std::string;
50 
51 
52 namespace util {
53 
54  template<int i>
55  struct StringConv<lib::meta::Num<i>>
56  {
57  static std::string
58  invoke (lib::meta::Num<i> num) noexcept
59  {
60  static util::_Fmt constElm("(%i)");
61  static util::_Fmt changedElm("{%i}");
62 
63  return string( (num.o_==i? constElm:changedElm) % int(num.o_));
64  }
65  };
66 
67 }
68 
69 namespace lib {
70 namespace meta {
71 namespace test {
72 
73 
74 
75  /* ===== printing Tuple types and contents ===== */
76 
77 
78  template<typename TUP>
79  inline enable_if<is_Tuple<TUP>,
80  string >
81  showType ()
82  {
83  using TypeList = typename RebindTupleTypes<TUP>::List;
84  using DumpPrinter = InstantiateChained<TypeList, Printer, NullP>;
85 
86  return "TUPLE"
87  + DumpPrinter::print();
88  }
89 
90  // see the macros DISPLAY and DUMPVAL defined in typelist-diagnostics.hpp
91 
92 
93 
94 
95 }}} // namespace lib::meta::test
96 #endif
Definition: run.hpp:49
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:399
constant-wrapper type for debugging purposes, usable for generating lists of distinguishable types ...