/
include_fmtlib.hpp
83 lines (66 loc) · 1.4 KB
/
include_fmtlib.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
/*
* RESTinio
*/
/*!
* \file
* \brief A special wrapper around fmtlib include files.
* \since
* v.0.5.1.2
*/
#pragma once
// Because fmt can include `windows.h` we should include
// Asio's header before fmt.
//
// Since v.0.6.1
#include <restinio/asio_include.hpp>
#if defined(__GNUG__) || defined(__clang__)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wpedantic"
#pragma GCC diagnostic ignored "-Wimplicit-fallthrough"
#if defined(__clang__)
#pragma GCC diagnostic ignored "-Wgnu-string-literal-operator-template"
#endif
#endif
#include <fmt/format.h>
#include <fmt/ostream.h>
#if FMT_VERSION < 60000
#include <fmt/time.h>
#else
#include <fmt/chrono.h>
#endif
// Workaround for absence of fmt::runtime in fmtlib prior to v8.0.0.
namespace restinio
{
namespace fmtlib_tools
{
#if FMT_VERSION < 80000
inline auto
runtime_format_string( const char * fmt_string ) noexcept
{
return fmt_string;
}
#else
inline auto
runtime_format_string( const char * fmt_string )
{
return fmt::runtime( fmt_string );
}
#endif
#if FMT_VERSION < 90000
template< typename T >
decltype(auto) streamed( T && v ) noexcept
{
return std::forward<T>(v);
}
#else
template< typename T >
decltype(auto) streamed( T && v ) noexcept
{
return fmt::streamed( std::forward<T>(v) );
}
#endif
} /* namespace fmtlib_tools */
} /* namespace restinio */
#if defined(__GNUG__) || defined(__clang__)
#pragma GCC diagnostic pop
#endif