spdlog
Loading...
Searching...
No Matches
bench
bench/utils.h
Go to the documentation of this file.
1
//
2
// Copyright(c) 2015 Gabi Melman.
3
// Distributed under the MIT License (http://opensource.org/licenses/MIT)
4
//
5
6
#pragma once
7
8
#include <
iomanip
>
9
#include <
locale
>
10
#include <
sstream
>
11
12
namespace
utils
{
13
14
template
<
typename
T>
15
inline
std::string
format
(
const
T
&
value
)
16
{
17
static
std::locale
loc(
""
);
18
std::stringstream
ss;
19
ss.
imbue
(loc);
20
ss <<
value
;
21
return
ss.
str
();
22
}
23
24
template
<>
25
inline
std::string
format
(
const
double
&
value
)
26
{
27
static
std::locale
loc(
""
);
28
std::stringstream
ss;
29
ss.
imbue
(loc);
30
ss <<
std::fixed
<<
std::setprecision
(1) <<
value
;
31
return
ss.
str
();
32
}
33
34
}
// namespace utils
std::string
std::stringstream
value
Definition
core.h:1120
T
T
Definition
core.h:320
std::fixed
T fixed(T... args)
std::stringstream::imbue
T imbue(T... args)
iomanip
locale
utils
Definition
bench/utils.h:12
utils::format
std::string format(const T &value)
Definition
bench/utils.h:15
std::setprecision
T setprecision(T... args)
sstream
std::stringstream::str
T str(T... args)
Generated by
1.9.8