tlx
Toggle main menu visibility
Loading...
Searching...
No Matches
tuple.hpp
Go to the documentation of this file.
1
/*******************************************************************************
2
* tlx/logger/tuple.hpp
3
*
4
* Part of tlx - http://panthema.net/tlx
5
*
6
* Copyright (C) 2018 Timo Bingmann <tb@panthema.net>
7
*
8
* All rights reserved. Published under the Boost Software License, Version 1.0
9
******************************************************************************/
10
11
#ifndef TLX_LOGGER_TUPLE_HEADER
12
#define TLX_LOGGER_TUPLE_HEADER
13
14
#include <
tlx/logger/core.hpp
>
15
#include <
tlx/meta/call_foreach_tuple_with_index.hpp
>
16
17
#include <tuple>
18
19
namespace
tlx
{
20
21
class
LoggerTupleFormatter
22
{
23
public
:
24
explicit
LoggerTupleFormatter
(std::ostream& os) :
os_
(os) { }
25
template
<
typename
Index,
typename
Arg>
26
void
operator ()
(
const
Index&,
const
Arg& a)
const
{
27
if
(Index::index != 0)
os_
<<
','
;
28
LoggerFormatter<typename std::decay<Arg>::type
>::print(
os_
, a);
29
}
30
std::ostream&
os_
;
31
};
32
33
template
<
typename
... Args>
34
class
LoggerFormatter
<
std
::tuple<Args...> >
35
{
36
public
:
37
static
void
print
(std::ostream& os,
const
std::tuple<Args...>& t) {
38
os <<
'('
;
39
call_foreach_tuple_with_index
(
LoggerTupleFormatter
(os), t);
40
os <<
')'
;
41
}
42
};
43
44
template
<>
45
class
LoggerFormatter
<
std
::tuple<> >
46
{
47
public
:
48
static
void
print
(std::ostream& os,
const
std::tuple<>&) {
49
os <<
'('
<<
')'
;
50
}
51
};
52
53
}
// namespace tlx
54
55
#endif
// !TLX_LOGGER_TUPLE_HEADER
56
57
/******************************************************************************/
call_foreach_tuple_with_index.hpp
tlx::LoggerFormatter< std::tuple< Args... > >::print
static void print(std::ostream &os, const std::tuple< Args... > &t)
Definition
tuple.hpp:37
tlx::LoggerFormatter< std::tuple<> >::print
static void print(std::ostream &os, const std::tuple<> &)
Definition
tuple.hpp:48
tlx::LoggerFormatter
template class for formatting. contains a print() method.
Definition
core.hpp:25
tlx::LoggerTupleFormatter
Definition
tuple.hpp:22
tlx::LoggerTupleFormatter::operator()
void operator()(const Index &, const Arg &a) const
Definition
tuple.hpp:26
tlx::LoggerTupleFormatter::LoggerTupleFormatter
LoggerTupleFormatter(std::ostream &os)
Definition
tuple.hpp:24
tlx::LoggerTupleFormatter::os_
std::ostream & os_
Definition
tuple.hpp:30
tlx::call_foreach_tuple_with_index
void call_foreach_tuple_with_index(Functor &&f, Tuple &&t)
Call a generic functor (like a generic lambda) to each components of a tuple together with its zero-b...
Definition
call_foreach_tuple_with_index.hpp:45
core.hpp
std
STL namespace.
tlx
Definition
exclusive_scan.hpp:17
tlx
logger
tuple.hpp
Generated on
for tlx by
1.17.0